2011-04-30 14 views
29

Me gustaría implementar un ExpandableListView que debería ser expansible solo después de que se hayan configurado todos los valores dentro del adaptador. También me gustaría poder desactivar el colapso del expansor.Cómo deshabilitar el colapso de una ExpandableListView?

¿Puedo lograr esto dentro de un diseño XML de Android?

Saludos,
Un Jabeer Ali

Respuesta

93

Se puede definir una OnGroupClickListener que devuelve true, así:

expandableList.setOnGroupClickListener(new OnGroupClickListener() { 
    @Override 
    public boolean onGroupClick(ExpandableListView parent, View v, 
           int groupPosition, long id) { 
    return true; // This way the expander cannot be collapsed 
    } 
}); 
6

no hay manera que yo sepa que esto se haga a partir de XML.

Se podría añadir un OnGroupClickListener a la ExpandableListView, y consumir su caso, si el grupo ya se expande:

myExpandableListView.setOnGroupClickListener(new OnGroupClickListener() 
{ 
    @Override 
    public boolean onGroupClick(ExpandableListView parent, 
     View v, int groupPosition, long id) 
    { 
     return parent.isGroupExpanded(groupPosition); 
    } 
}); 
+0

Gracias Tú mucho. Pero he hecho algunos cambios y funcionó para no recopilar la lista – Jabeer

+0

Muchas gracias. Pero he hecho algunos cambios en él y ha funcionado por no collepse la listid.setOnGroupCollapseListener (nueva OnGroupCollapseListener() { \t \t \t \t \t \t pública onGroupCollapse vacío (int id) { \t \t \t \t // TODO Auto método generado stub \t \t \t \t ExpandableListView ampliar = (ExpandableListView) findViewById (R.id.expandableListView1); \t \t \t \t expand.expandGroup (id); \t \t \t} \t \t}); – Jabeer

+0

te echo mucho en falta. Pero he hecho algunos cambios y funcionó para no recopilar el listid.setOnGroupCollapseListener (nuevo OnGroupCollapseListener() {public void onGroupCollapse (int id) {// TODO stub de método generado automáticamente ExpandibleListView expand = (ExpandableListView) findViewById (R. id.expandableListView1); expand.expandGroup (id);}}); – Jabeer

Cuestiones relacionadas