【发布时间】:2015-01-30 07:19:06
【问题描述】:
当我滚动我的动态数据时,我的动态数据正在随机播放。任何方式我都可以阻止它。我也尝试过视图持有者,但没有运气。我做错了什么。一些帮助会很好。在此先感谢
public View getView(int position, View convertView, ViewGroup arg2) {
TextView title, title_sub1, title_sub2, sub1, sub2;
ImageView img, lock;
boolean isenable = false;
try
{
if (convertView == null)
{
convertView = RelativeLayout.inflate(context, R.layout.protection_home, null);
}
int label;
int icon;
if (mFeatures != null)
{
label = mFeatures.get(position).label;
icon = mFeatures.get(position).icon;
isenable = mFeatures.get(position).isenable;
} else
{
label = item[position];
icon = itemimg[position];
}
title = (TextView) convertView.findViewById(R.id.pro_title);
title_sub1 = (TextView) convertView.findViewById(R.id.sub_title1);
title_sub2 = (TextView) convertView.findViewById(R.id.sub_title2);
img = (ImageView) convertView.findViewById(R.id.icon);
sub1 = (TextView) convertView.findViewById(R.id.title1_status);
sub2 = (TextView) convertView.findViewById(R.id.title2_status);
lock = (ImageView) convertView.findViewById(R.id.lock);
title.setText(label);
img.setImageResource(icon);
title_sub1.setText(Setsubtitle1(label));
title_sub2.setText(Setsubtitle2(label));
sub1.setText("OFF");
sub2.setText("ON");
if (isenable == false)
{
convertView.setBackgroundResource(R.color.layout_default_bg_color_gray);
} else
{
convertView.setBackgroundResource(R.color.layout_default_bg_color_white);
}
convertView.setId(label);
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return convertView;
}
【问题讨论】:
-
尝试为此目的使用 Volley 库。谷歌它或检查 Androidhive。干杯!
标签: java android android-listview