当前位置:编程学习 > wap >>

这个算是自定义的组件吧?怎么用,会报错

xml:
<com.lyx.SingleWeatherInfoView android:id="@+id/weather_0"android:layout_width="wrap_content" android:layout_height="wrap_content"
/>

java代码


package com.lyx;

import android.content.Context;
import android.widget.LinearLayout;

public class SingleWeatherInfoView extends LinearLayout
{

public SingleWeatherInfoView(Context context)
{
super(context);
// TODO Auto-generated constructor stub
}

}


在XML中写了
<com.lyx.SingleWeatherInfoView android:id="@+id/weather_0"android:layout_width="wrap_content" android:layout_height="wrap_content"
/>
SingleWeatherInfoView 是类名。顺着意思我又建了个SingleWeatherInfoView并继承了LinearLayout
。继承了LinearLayout我是参考代码的。在做天气预报的小程序参考代码的。
但是这样建了后程序运行部了,会报错。请问还要添加什么?或要配置之类的?求解释,谢谢 --------------------编程问答-------------------- 请附加Log。 目测下应该是要重载如下构造方法:
    public SingleWeatherInfoView (Context context, AttributeSet attrs) --------------------编程问答--------------------  路上的说法是对滴~ 
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,