我有两个主要的主要数据和数据。
在数据中我有3个属性:
nombre;---> the name of the team
imagen;--->logo of the team
web;--->and team webpage
Datos类:
public class Datos {
private String nombre, website;
private int imagen;
public Datos(String nombre, String website, int imagen) {
this.nombre = nombre;
this.website = website;
this.imagen = imagen;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
public int getImagen() {
return imagen;
}
public void setImagen(int imagen) {
this.imagen = imagen;
}
}
主:
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlayout);
spinner = (Spinner)findViewById(R.id.spinner);
cargaspinner();
}
public void cargaspinner(){
ArrayList<datos> datosArrayList = new ArrayList<datos>();
datosArrayList.add(new datos("Barcelona", barcelona.com, ??));
ArrayAdapter<datos> adapter = new ArrayAdapter(this, R.layout.support_simple_spinner_dropdown_item, datosArrayList);
spinner.asetAdapter(adapter);
}
答案 0 :(得分:0)
图标/绘图在android中基本上是int
所以你可以声明图像/图标列表如下:
List<Integer> icons = new ArrayList<>();
icons.add(R.drawable.icon1);
icons.add(R.drawable.icon2);
如果您需要更多帮助,请在下方发表评论
答案 1 :(得分:0)
所以你必须修改这样的方法:
public void cargaspinner(){
ArrayList<Datos> datosArrayList = new ArrayList<Datos>();
datosArrayList.add(new Datos("Barcelona", "http://www.barcelona.com", R.drawable.image));
ArrayAdapter<Datos> adapter = new ArrayAdapter(this, R.layout.support_simple_spinner_dropdown_item, datosArrayList);
spinner.asetAdapter(adapter);
}