I can't do ListView adapter of ArrayList because
the whole of data is from SQLite
final ArrayList<String> list= helper.GetAllValues("x1", column2);
//final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list);
final ListAdapter adapter = new ListAdapter(this, list, img);
listview.setAdapter(adapter);
ListAdapter.java
public class ListAdapter extends ArrayAdapter<String> {
private final Activity context;
private final String[] itemname;
private final Integer[] imgid;
public ListAdapter(Activity context, String[] itemname, Integer[] imgid) {
super(context, R.layout.items, 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.items, null,true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.TitleLabel);
ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
TextView extratxt = (TextView) rowView.findViewById(R.id.SecondLabel);
txtTitle.setText(itemname[position]);
imageView.setImageResource(imgid[position]);
extratxt.setText("Description "+itemname[position]);
return rowView;
};
}
Error:(66, 37) error: constructor ListAdapter in class ListAdapter cannot be applied to given types;
required: Activity,String[],Integer[]
found: Listofmeals,ArrayList,Integer[]
reason: actual argument ArrayList cannot be converted to String[] by method invocation conversion
private final String[] itemname;
private final Integer[] imgid;
It's wrong the same as this:
txtTitle.setText(itemname[position]);
imageView.setImageResource(imgid[position]);
extratxt.setText("Description "+itemname[position]);
How type Arraylist I have to insert?
Aucun commentaire:
Enregistrer un commentaire