大佬教程收集整理的这篇文章主要介绍了android – BaseAdapter导致ListView在滚动时出错,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
很难描述确切的行为,但是很容易看出你是否选择了50个项目的排序列表,并开始向上和向下滚动.
class ContactAdapter extends BaseAdapter { ArrayList<Contact> mContacts; public ContactAdapter(ArrayList<Contact> contacts) { mContacts = contacts; } @Override public int getCount() { return mContacts.size(); } @Override public Object getItem(int position) { return mContacts.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position,View convertView,ViewGroup parent) { View view; if(convertView == null){ LayoutInflater li = getLayoutInflater(); view = li.inflate(R.layout.groups_item,null); TextView label = (TextView)view.findViewById(R.id.groups_item_titlE); label.setText(mContacts.get(position).getName()); label = (TextView)view.findViewById(R.id.groups_item_subtitlE); label.setText(mContacts.get(position).getnumber()); } else { view = convertView; } return view; } }
TextView label = (TextView)view.findViewById(R.id.groups_item_titlE); label.setText(mContacts.get(position).getName()); label = (TextView)view.findViewById(R.id.groups_item_subtitlE); label.setText(mContacts.get(position).getnumber());
在if / else块之后和方法返回之前,所以您可以更新TextView小部件,无论是回收该行还是创建新的行.
以上是大佬教程为你收集整理的android – BaseAdapter导致ListView在滚动时出错全部内容,希望文章能够帮你解决android – BaseAdapter导致ListView在滚动时出错所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。