我将此适配器用于我的 ListView:
Appadapter extends ArrayAdapter<ResolveInfo>
private PackageManager pm=null;
List<ResolveInfo> apps;
AppAdapter(PackageManager pm, List<ResolveInfo> apps) {
super(Launchalot.this, R.layout.row, apps);
this.apps=apps;
this.pm=pm;
}
@Override
public View getView(int position, View convertView,
ViewGroup parent) {
Log.w(Launchalot.this.getPackageName(),"getView");
if (convertView==null) {
convertView=newView(parent);
}
bindView(position, convertView);
return(convertView);
}
private View newView(ViewGroup parent) {
Log.w(Launchalot.this.getPackageName(),"newView");
return(getLayoutInflater().inflate(R.layout.row, parent, false));
}
private void bindView(int position, View row) {
TextView label=(TextView)row.findViewById(R.id.label);
Log.w(Launchalot.this.getPackageName(),"bindView");
label.setText(getItem(position).loadLabel(pm));
ImageView icon=(ImageView)row.findViewById(R.id.icon);
icon.setImageDrawable(getItem(position).loadIcon(pm));
}
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
setNotifyOnChange(true);}}
我在 ListActivity 类中使用此代码填充我的视图:
AppAdapter adapter=new AppAdapter(getPackageManager(), getResolveInfoList(0));
setListAdapter(adapter);
现在我已经更改了我称为 notifyDataSetChanged() 的列表应用程序,但我认为没有任何改变。请告诉我一个解决方案。谢谢