繁体   English   中英

Android-此类应提供默认构造函数

[英]Android - This Class Should Provide a Default Constructor

当我想生成签名应用程序时,它告诉我:

   Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.example.discopc.beautiyuser.Customy) [Instantiatable]

我的项目 :

public class Customy extends ArrayAdapter<String> {

private final Activity context;
        View v;
private final String[]name;

public Customy(Activity context, String[] name){
        //super(null,0);
        super(context,R.layout.activity_customy,name);


        this.context=context;
        this.name=name;



        }


public View getView(final int position,View convertView,ViewGroup parent){
        try{



        LayoutInflater infalter=context.getLayoutInflater();
        v=infalter.inflate(R.layout.activity_customy,null,true);
                TextView txtName=(TextView)v.findViewById(R.id.name);


        txtName.setText(""+name[position]+"");

        }catch(Exception e){

        }
        return v;
        }
}

注意:在我的android设备上调试时 ,它可以正常工作,但我不能

生成>生成签名的应用

我真的不知道该怎么办。

谢谢 ,

默认构造函数是没有参数且可以隐式使用的类的构造函数。

public Customy( /* notice - no arguments */) {
    // your code here
}

但是就您而言-这一定不是问题。 问题是,您的类在XML配置中某个类的某个框架正在尝试使用默认构造函数将其实例化,而我们显然看到您需要将2个参数传递给构造函数才能使类实例起作用。

错误检查您是否已在Android Manifest中添加了该适配器名称。 如果是,请将其删除并尝试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM