这是我的myadapterclass的getview方法
public View getView(int position,View convertView,ViewGroup parent) { pos = position;
ApplicationInfo entry = ai.get(position);
String str = insatllApps.get(position);
System.out.println("Position============"+(insatllApps.get(position)));
//Log.d("Check>>:","size>>"+insatllApps.size());
convertView = mInflater.inflate(R.layout.list__button, null);
t1=(TextView)convertView.findViewById(R.id.textView1);
iv=(ImageView)convertView.findViewById(R.id.imageView1);
tb1=(ToggleButton)convertView.findViewById(R.id.togal);
tb1.setOnClickListener(this);
tb1.setTag(pos);
tb1.setTag(R.id.togal, str);
iv.setImageDrawable(entry.loadIcon(mPackManager));
t1.setText(str);
return convertView;
}
答案 0 :(得分:-1)
这是有效的解决方案
View row=null
ApplicationInfo entry = ai.get(position);
String str = insatllApps.get(position);
System.out.println("Position============"+(insatllApps.get(position)));
//Log.d("Check>>:","size>>"+insatllApps.size());
row= mInflater.inflate(R.layout.list__button, null);
t1=(TextView)row.findViewById(R.id.textView1);
iv=(ImageView)row.findViewById(R.id.imageView1);
tb1=(ToggleButton)row.findViewById(R.id.togal);
tb1.setOnClickListener(this);
tb1.setTag(pos);
tb1.setTag(R.id.togal, str);
iv.setImageDrawable(entry.loadIcon(mPackManager));
t1.setText(str);
return row
在getView方法中创建一个新视图