【发布时间】:2011-10-31 14:53:56
【问题描述】:
I am wanting to create a Spinner from an ArrayList of Objects I have created and therefore when one is selected I can go back to that ArrayList and get the rest of the information from it
例子
public class ObjectName {
private int ID;
private String name;
private String name2;
public ObjectName{int pID, String pName, String pName2) {
ID = pID;
name = pName;
name2 = pName2;
}
//Getters Here
}
微调器代码示例
ArrayList<ObjectName> objects = new ArrayList<ObjectName>;
ArrayAdapter<ObjectName> adapter = new ArrayAdapter<ObjectName>(this, android.R.layout.simple_spinner_item, objects);
当然,微调器不会显示我想要的。有没有简单的方法来解决这个问题
感谢您的宝贵时间
【问题讨论】:
-
您在哪里将值添加到 ArrayList?
-
从另一个类创建 Arraylist(从数据库中提取数据)
标签: android