[英]While scrolling the list ,the items in list are getting jumbled
While scrolling the list ,the items in list are getting jumbled. 滚动列表时,列表中的项目变得混乱。 I am using the base adapter for custom list.
我将基本适配器用于自定义列表。
My code is: 我的代码是:
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = View.inflate(context, R.layout.list_challenge_comp_cell, null);
holder.text_title = (TextView) convertView.findViewById(R.id.text_title);
holder.text_challenge = (TextView) convertView.findViewById(R.id.text_challenge);
holder.text_enroll_date = (TextView) convertView.findViewById(R.id.text_enroll_date);
holder.text_rewards = (TextView) convertView.findViewById(R.id.text_rewards);
holder.button_share = (Button) convertView.findViewById(R.id.button_enroll);
holder.progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
holder.layout_main = (LinearLayout)convertView.findViewById(R.id.layout_main);
holder.progressBar.setVisibility(View.VISIBLE);
holder.button_share.setText("Share");
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Add the code in adapter, 在适配器中添加代码,
@Override
public int getViewTypeCount() {
// The total number of row types your adapter supports.
// This should NEVER change at runtime.
return VIEW_TYPE_COUNT;
}
@Override
public int getItemViewType(int position) {
// return a value from zero to (viewTypeCount - 1)
if (position == 0) {
return VIEW_TYPE_HEADER;
} else if (position == getCount() - 1) {
return VIEW_TYPE_FOOTER;
}
return VIEW_TYPE_DEFAULT;
}
and use 和使用
View holder
查看支架
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.