2010-08-05 11 views

Odpowiedz

20

Musisz subskrybować setOnChildClickListener

getExpandableListView().setOnChildClickListener(this); 

i wdrożenie OnChildClickListener

@Override 
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, 
     int childPosition, long id) { 
    // use groupPosition and childPosition to locate the current item in the adapter 
    return true; 
} 
+0

Czy ten stosuje się do przykładu I powiązany? Wygląda na to, że ten przykład nie implementuje ExpandableListView – user412164

+0

Oczywiście, że rozszerza 'ExpandableListActivity' – Pentium10

+0

Dziękuję. Czy wiesz, jaki jest właściwy sposób uzyskania wartości lub "etykiety" klikniętego dziecka? – user412164

1

powinny przesłonić onChildClick w rozszerzeniu ExpandableListActivity.

+0

Jak mogę otrzymać wybrane dziecko po nadpisaniu? – Mikey

2

Należy określić lokalizację elementów w rozszerzalnej listy jak ten

listView.setOnChildClickListener(new OnChildClickListener() 
{ 
    @Override 
    public boolean onChildClick(ExpandableListView parent, View v, int group_position, int child_position, long id) 
    { 
     if(group_position==0 && child_position==0){ 
      TryFragment secondFragment = (TryFragment) SampleActivity.this.getFragmentManager().findFragmentById(R.id.tryFragment); 
      secondFragment.getView().setVisibility(View.VISIBLE); 
     } else if(group_position==2 && child_position==2){ 
      TryFragment secondFragment = (TryFragment) SampleActivity.this.getFragmentManager().findFragmentById(R.id.tryFragment); 
      secondFragment.getView().setVisibility(View.VISIBLE); 
     } 
     return false; 
    } 
}); 
Powiązane problemy