android自定义View的显示 public GameView(Context context) {super(context);}当组件用,这个构造方法中的参数换为两个的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 LayoutInflater inflater=LayoutInflater.from(this); //或者 //LayoutInflater inflater=getLayoutInflater(); View layout1=inflater.inflate(R.layout.test,null); Button bt1=(Button)layout1.findViewById(R.id.clickMeBtn);是获取两个xml文件中的组件吗 应该是构造方法有问题 需要重写public GameView(Context context,AttributeSet attributeSet){supe(context,attributeSet);} 重写一下含有两个参数的View构造函数就行了。 要将自定义的View控件配置到xml文件中必须要复写supe(context,attributeSet)构造方法,也就是AttributeSet attributeSet参数必须有,否则配置到xml也无法运行,public GameView(Context context,AttributeSet attributeSet){supe(context,attributeSet);} android Mediaplayer的简单程序 大神是怎么练成的? 【给点建议】从USB接口读取数据 TabHost下的listView用notifyDataSetChanged方法显示异常 bitmap ARGB问题 ,求助 程序崩溃 使用.startAnimation(xxx) android 程序启动问题 如何把源程序打包成.apk格式 使用adb调试安卓设备,端口遭其他程序占用,怎么解决 ADT安装问题,请求支援 android 3G应用开发 初步 TextView触发方法,在线等
//或者
//LayoutInflater inflater=getLayoutInflater();
View layout1=inflater.inflate(R.layout.test,null);
Button bt1=(Button)layout1.findViewById(R.id.clickMeBtn);是获取两个xml文件中的组件吗
public GameView(Context context,AttributeSet attributeSet)
{
supe(context,attributeSet);
}
public GameView(Context context,AttributeSet attributeSet)
{
supe(context,attributeSet);
}