我在使用convertview的listview上使用ArrayAdapter。但是當它滾動時,有一些項目重複。你能幫我解決問題嗎? getView功能的感謝 主要代碼:滾動時重複的列表視圖項目
View view;
if (null != convertView) {
view = convertView;
} else {
view = getActivity().getLayoutInflater().inflate(R.layout.item_fans_task, null);
taskImg = (ImageView) view.findViewById(R.id.task_img);
taskTitleText = (TextView) view.findViewById(R.id.task_title_text);
taskContentText = (TextView) view.findViewById(R.id.task_content_text);
taskProcessImg = (ImageView) view.findViewById(R.id.task_process_img);
shareText = (TextView) view.findViewById(R.id.share_text);
taskType = (TextView) view.findViewById(R.id.task_type);
}
Tasks task = getItem(position);
taskTitleText.setText(task.getTitle());
StringBuilder builder = new StringBuilder();
builder.append("已將文章分享到朋友圈,並獲得" + task.getReaders() +"次閱讀\n");
builder.append("已分享" + task.getTsum() + "次" + " 剩餘" + task.getSynum() + "次");
taskContentText.setText(builder);
...
return view;
也分享您的適配器代碼。 – dex
可能重複http://stackoverflow.com/questions/8261376/duplicated-entries-in-listview – DGN