android - expandablelistview with multiple textviews -
i have expandablelistview, parent has 4 textviews , children, 4 textviews also.
i know how can populate if have 1 element on parent , 1 on child, 4 don't.
i think must have data in separate arraylists.
numerosservicios = new arraylist<string>(); profesiones = new arraylist<string>(); direcciones = new arraylist<string>(); fechascaduca = new arraylist<string>(); tipos = new arraylist<string>(); diasencurso = new arraylist<string>(); fechasproximascitas = new arraylist<string>(); estados = new arraylist<string>(); but don't know how should make adapter. see code don't understand it.
anyone has example please? thanks
edit
i found "solution":
private list<? extends list<? extends map<string, ?>>> crealistadehijos() { arraylist resultado_hijo = new arraylist(); for(int i=0;i<=arrayservicios.size();i++){ hashmap hijo = new hashmap(); hijo.put("tipo", tipos.get(i)); hijo.put("diasencurso", diasencurso.get(i)); hijo.put("estado", estados.get(i)); hijo.put("fechaprocita", fechasproximascitas.get(i)); resultado_hijo.add(hijo); } return (list)resultado_hijo; } private list<? extends map<string, ?>> crealistadegrupos() { arraylist resultado_padre = new arraylist(); for(int i=0;i<=arrayservicios.size();i++){ hashmap padre = new hashmap(); padre.put("numero_servicio", numerosservicios.get(i)); padre.put("profesion", profesiones.get(i)); padre.put("direccion", direcciones.get(i)); padre.put("fecha_cad", fechascaduca.get(i)); resultado_padre.add(padre); } return (list)resultado_padre; } simpleexpandablelistadapter explistadapter = new simpleexpandablelistadapter( contexto, crealistadegrupos(), r.layout.linea_padre, new string[] { "numero_servicio","profesion","direccion","fecha_cad" }, new int[] { r.id.tvservicio,r.id.tvprofesion,r.id.tvdireccion,r.id.tvdiasencurso}, crealistadehijos(), r.layout.linea_hija, new string[] { "tipo", "diasencurso","estado","fechaprocita" }, new int[] { r.id.tvtipo , r.id.tvdiasencurso, r.id.tvestado, r.id.tvfechaproximacita} ); setlistadapter( explistadapter ); registerforcontextmenu(getexpandablelistview());
Comments
Post a Comment