- Posts del Foro: 3
24 oct. 2014 16:56:45 vía Web
24 oct. 2014 16:56:45 vía Web
Estimados foristas, tengo un inconveniente, resulta que debo cargar un listview con datos de una base Sql Server, pero esta lista debe mostrar una imagen para ello uso lazy adapter y imageloader. pero resulta que me carga en cada item de la lista solo el ultimo registro de la tabla de la bd. es como que queda siempre el ultimo. Alguien tuvo el mismo problema?? abajo el codigo:
MainActivity
resultado = statement.executeQuery(ComandoSql);
List<Map<String, String>> data = null;
data = new ArrayList<Map<String,String>>();
ArrayList<HashMap<String, String>> ListEven = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
while(resultado.next()){
map.put("A", resultado.getString("EventoNombre");
map.put("B", resultado.getString("EventoFecha");
map.put("C", resultado.getString("EventoFoto");
ListEven.add(map);
}
lista = (ListView)findViewById(R.id.listaEventos);
adapter=new LazyAdapter(this, ListEven);
lista.setAdapter(adapter);
LazyAdapter
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.modelo, null);
TextView nombreEvento = (TextView)vi.findViewById(R.id.txtNombreEvento);
TextView fechaEvento = (TextView)vi.findViewById(R.id.txtFechaEvento);
ImageView fotoEvento = (ImageView)vi.findViewById(R.id.fotoEvento);
HashMap<String, String> eventos = new HashMap<String, String>();
eventos = data.get(position);
nombreEvento.setText(eventos.get("A");
fechaEvento.setText(eventos.get("B");
imageLoader.DisplayImage(eventos.get("C", fotoEvento);
return vi;
}
Muchas gracias por su tiempo. Saludos
Contenido editorial recomendado
Con su consentimiento, aquí se cargan contenidos externos.
Al hacer clic en el botón anterior, acepta que se le muestren contenidos externos. En el proceso pueden transmitirse datos personales a terceros proveedores. Encontrará más información al respecto en nuestro Política de privacidad.