I want to add a different type of item (like a simple textview) to the last position in my ListView
.
I extends the SimpleAdapter
and override some methods:
@Override
public int getCount() {
if (super.getCount() == 0) {
return 0;
} else {
return super.getCount() + 1;
}
}
@Override
public Object getItem(int position) {
if (position == getCount() - 1) {
return null;
} else {
return super.getItem(position);
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v;
if (position == getCount() - 1) {
if (convertView == null) {
v = new TextView(mContext);
} else {
v = convertView;
}
return v;
} else {
return super.getView(position, convertView, parent);
}
}
But it did not work. What is the problem or how to add one? Thanks.