我正在廣泛地學習有關獲取者和安裝者的知識,但我似乎沒有按照自己的方式。 我有一個名爲Apps_Info的類,其中包含我的setters和getters,我有我的主要活動FavouriteApps,它有一個使用Apps_Info類的列表。
我想從FavouriteApps列表中獲取包的名稱,但我仍然收到null。
請有人可以告訴該怎麼辦?下面是這個命令的代碼:類Apps_Info和FavouriteApps活動安裝者和獲得者的信息
public class Apps_Info {
private Bitmap bIcon;
private String sName;
private String sPacks_Name;
public Apps_Info(Bitmap icon, String name, String Packs_Name) {
bIcon = icon;
sName = name;
sPacks_Name = Packs_Name;
}
public void setIcon(Bitmap icon) {
bIcon=icon;
}
public Bitmap getIcon() {
return bIcon;
}
public void setName(String name) {
sName=name;
}
public String getName() {
return sName;
}
public void setPacks_Name(String Packs_Name) {
this.sPacks_Name=Packs_Name;
}
public String getPacks_Name() {
return sPacks_Name;
}
}
FavouriteApps活動代碼(部分)
String packname, packsname, apps_names;
Bitmap app_icon;
Resources res = getResources();
List<Apps_Info> ListApps_Info = new ArrayList<Apps_Info>();
ListApps_Info.add(new Apps_Info(BitmapFactory.decodeResource(res, R.drawable.browser_app), "Browser", "com.browser"));
ListApps_Info.add(new Apps_Info(BitmapFactory.decodeResource(res, R.drawable.clock_app), "Alarm Clock", "com.alarm.clock"));
ListApps_Info.add(new Apps_Info(BitmapFactory.decodeResource(res, R.drawable.threegplus), "3G Secure Connection", "threeg.secureconnect"));
mGridView.setAdapter(new Apps_Info_Adapter(this, ListApps_Info));
Apps_Info packinfo = new Apps_Info(app_icon, apps_names, packname);
packsname = packinfo.getPacks_Name();
apps_names = packinfo.getName();
Log.i("The Pack_Name is " + packsname, "Pack Name");
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html – Jave 2012-02-21 10:46:31