错误:错误:此类应提供默认构造函数(不带参数的公共构造函数)(AppName.CustomListAdapter)[Instantiatable]

时间:2015-11-03 13:07:40

标签: constructor apk adapter signed custom-lists

我正在尝试为我的应用程序创建一个已签名的apk但是在创建签名的apk对话后单击完成后出现错误。

  

错误:错误:此类应提供默认构造函数(不带参数的公共构造函数)(MYAPPNAME.CustomListAdapter)[Instantiatable]

下面的Java代码

     import android.app.Activity;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.ImageView;
    import android.widget.TextView;

public class CustomListAdapter extends ArrayAdapter {

private final Activity context;
private final String[] itemname;
private final Integer[] imgid;

public CustomListAdapter(Activity context, String[] itemname, Integer[] imgid) {
    super(context, R.layout.mylist, itemname);
    // TODO Auto-generated constructor stub

    this.context=context;
    this.itemname=itemname;
    this.imgid=imgid;
}

public View getView(int position,View view,ViewGroup parent) {
    LayoutInflater inflater=context.getLayoutInflater();
    View rowView=inflater.inflate(R.layout.mylist, null,true);

    TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
    ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
    //TextView extratxt = (TextView) rowView.findViewById(R.id.textView1);

    txtTitle.setText(itemname[position]);
    imageView.setImageResource(imgid[position]);
   // extratxt.setText("Description "+itemname[position]);
    return rowView;

};

请帮助

1 个答案:

答案 0 :(得分:0)

问题已在build.gradle文件中解决。在android字符串中添加以下内容:

  lintOptions {
            abortOnError false
        }