I want to have a Listview adapter where each rows uses it’s own convertview,
so this convertview couldn’t be share to another row.
Basically, if I have 4 rows, I would like to have 4 convertview.
And when drawing the row #3 I should get the convertview #3
To do this I setted each row a different type (it’s position)
I thought it would do the trick.
public class myadapter extends BaseAdapter {
final List<String> mdata;
@Override
public int getCount() {
return mdata.size();
}
@Override
public Object getItem(int p) {
return p;
}
@Override
public long getItemId(int p) {
return p;
}
@Override
public int getItemViewType(int p) {
return p;
}
@Override
public int getViewTypeCount() {
return mdata.size() == 0 ? 1 :mdata.size() + 1;
}
@Override
public View getView(int p, View v, ViewGroup arg2) {
ViewHolder holder = null;
if (v == null) {
v = li.inflate(R.layout.data, null);
holder = new ViewHolder();
holder._pos = p;
Log.v("TAG", "creating holder pos " + p + " for " + mdata.get(p));
{...}
v.setTag(holder);
} else {
holder = (ViewHolder)v.getTag();
Log.d("TAG", "get convert for " + mdata.get(p)+ " holder " + holder._pos);
}
{...}
return v;
}
public static class ViewHolder {
public TextView _textView;
public int _pos;
}
}
Note the pos in the viewholder is only here to debug purpose.
Unfortunatly it displays:
creating holder pos 0 for string0
creating holder pos 1 for string1
get convert for string0 holder 1
get convert for string0 holder 0
get convert for string1 holder 1
How the get convert for string0 holder 1 is possible ?
Thanks
I found the problem,
could not change during the execution of the program.
You have to set it to a big value, even if you use less. It has to be a constant.