我有一个绑定到列表视图的自定义适配器。那部分很好。当我滚动列表视图时,排序被抛出,因为如果我滚动回到开头(即向下滚动后向上滚动),显示的 TextView 不是第一个。在滚动过程中我必须在适配器中处理什么吗?
public class TextViewAdapter extends BaseAdapter
{
private Context context;
public TextViewAdapter(Context c)
{
context = c;
}
//---returns the number of images---
public int getCount() {
return textViews.size();
}
//---returns the ID of an item---
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
//---returns an TextView---
public View getView(int position, View convertView, ViewGroup parent)
{
TextView tv;
Log.d("Position", Integer.toString(position));
if (convertView == null) {
tv = (TextView)textViews.get(position);
} else {
tv = (TextView) convertView;
}
return tv;
}
}