问题描述
- horizontallistview充填数组图片
-
修改gallery控制,读取Devsmart horizontallistview控制,运行不起来。有一个来自网络服务器的整型数组,动态充填原来的gallery控制,怎么充填horizontalllistview?
private void llenagallery() { int i,Id; for ( i = 0; i<(Servicios.length()); i++) { String valor = Character.toString(Servicios.charAt(i)); if (valor.equals("a")) { Id = this.getResources().getIdentifier("a", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("b")) { Id = this.getResources().getIdentifier("b", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("c")) { Id = this.getResources().getIdentifier("c", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("d")) { Id = this.getResources().getIdentifier("d", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("e")) { Id = this.getResources().getIdentifier("e", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("f")) { Id = this.getResources().getIdentifier("f", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("g")) { Id = this.getResources().getIdentifier("g", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("i")) { Id = this.getResources().getIdentifier("i", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("j")) { Id = this.getResources().getIdentifier("j", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("l")) { Id = this.getResources().getIdentifier("l", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("m")) { Id = this.getResources().getIdentifier("m", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("n")) { Id = this.getResources().getIdentifier("n", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("o")) { Id = this.getResources().getIdentifier("o", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("p")) { Id = this.getResources().getIdentifier("p", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("r")) { Id = this.getResources().getIdentifier("r", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("s")) { Id = this.getResources().getIdentifier("s", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("t")) { Id = this.getResources().getIdentifier("t", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("u")) { Id = this.getResources().getIdentifier("u", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("v")) { Id = this.getResources().getIdentifier("v", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("w")) { Id = this.getResources().getIdentifier("w", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("y")) { Id = this.getResources().getIdentifier("y", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("z")) { Id = this.getResources().getIdentifier("z", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("P")) { Id = this.getResources().getIdentifier("euro1", "drawable", this.getPackageName()); imagenes.add(Id); }else if (valor.equals("h")) { Id = this.getResources().getIdentifier("euro2", "drawable", this.getPackageName()); imagenes.add(Id); } } HorizontalListView hscroll = (HorizontalListView)findViewById(R.id.iconos); hscroll.setAdapter(new ImageAdapter(this,imagenes));
调试程序时,什么也没显示。
解决方案
要看Adapter怎么写的了
时间: 2024-11-08 17:52:42