When I used a custom list array adapter for list view, the data are shown on the list but are not clickable. I already set a listener on a listview item click, but it's not working.
Also, I found another solution to make rows clickable and set background drawable on linear layout list view item layout but it's a bad trick to use this solution.
Is there any other solution for this?
Can any body tell me why does this happen? In list view which default functionality not working on custom array adapter
Here is my code:
public class Model {
String name;
String id;
String price;
}
mArrayList = new ArrayList<Model>();
// mArrayList has some data in it
mListiView.setsetAdapter(new myCoustomAdapter(mContext, mArrayList));
mListiView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getBaseContext(), ""+position, Toast.LENGTH_LONG).show();
}
});
public class myCoustomAdapter extends ArrayAdapter<Model> {
ArrayList<Model> mList;
public myCoustomAdapter(Context context, ArrayList<Model> list) {
super(context, R.layout.item);
this.mList=list;
}
@Override
public int getCount() {
return this.mList.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// layout data here
return view;
}
}
Nothing happens on item click.