public final class listadpter extends BaseAdapter{
LayoutInflater inflater;
List<PackageInfo> pkinfos;
public listadpter(Context context,List<PackageInfo> packinfos) {
this.pkinfos=packinfos;
inflater = LayoutInflater.from(context);
}
public int getCount() {
int position=pkinfos.size();
return position;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
//获得布局文件的带有所有控件的容器
View view = inflater.inflate(R.layout.lv_item, null);
//找到布局文件的一个textview
TextView appname = (TextView) view.findViewById(R.id.appname);
//找到布局文件的一个textview
TextView packname=(TextView) view.findViewById(R.id.packagename);
//找到布局文件的一个imageview
ImageView appicon= (ImageView) view.findViewById(R.id.icon);
//把所有的一个包和程序的信息设置进三个控件中
appname.setText(pkinfos.get(position).applicationInfo
.loadLabel(getPackageManager()));
appicon.setImageDrawable(pkinfos.get(position).applicationInfo
.loadIcon(getPackageManager()));
packname.setText(pkinfos.get(position).packageName);
return view;
}}
LayoutInflater inflater;
List<PackageInfo> pkinfos;
public listadpter(Context context,List<PackageInfo> packinfos) {
this.pkinfos=packinfos;
inflater = LayoutInflater.from(context);
}
public int getCount() {
int position=pkinfos.size();
return position;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
//获得布局文件的带有所有控件的容器
View view = inflater.inflate(R.layout.lv_item, null);
//找到布局文件的一个textview
TextView appname = (TextView) view.findViewById(R.id.appname);
//找到布局文件的一个textview
TextView packname=(TextView) view.findViewById(R.id.packagename);
//找到布局文件的一个imageview
ImageView appicon= (ImageView) view.findViewById(R.id.icon);
//把所有的一个包和程序的信息设置进三个控件中
appname.setText(pkinfos.get(position).applicationInfo
.loadLabel(getPackageManager()));
appicon.setImageDrawable(pkinfos.get(position).applicationInfo
.loadIcon(getPackageManager()));
packname.setText(pkinfos.get(position).packageName);
return view;
}}