public GameView(Context context) {
super(context);
}
当组件用,这个构造方法中的参数换为两个的。

解决方案 »

  1.   

            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文件中的组件吗
      

  2.   

    应该是构造方法有问题 需要重写
    public GameView(Context context,AttributeSet attributeSet)

    supe(context,attributeSet);

      

  3.   

    重写一下含有两个参数的View构造函数就行了。
      

  4.   

    要将自定义的View控件配置到xml文件中必须要复写supe(context,attributeSet)构造方法,也就是AttributeSet attributeSet参数必须有,否则配置到xml也无法运行,
    public GameView(Context context,AttributeSet attributeSet)

    supe(context,attributeSet);