2017-09-11 1 views
-1

Je me demandais comment implémenter un "onChildChildClickListener" dans cette vue de liste extensible à trois niveaux après avoir répondu à la question de savoir comment remplir la vue de liste extensible à trois niveaux (Populate different arrays in third layer of expandableListView)."onChildChildClick" vue de liste extensible à trois niveaux

Comment peut-on implémenter le troisième niveau pouvant être cliqué?

Exemple de code par BKN est publié sur githube ici: https://github.com/ngocchung/ThreeLevelExpListView

Est-ce que quelqu'un a une idée? L'aide serait heureusement appréciée car je voudrais l'implémenter dans une application de démonstration dans le cadre de ma Masterthesis.

Répondre

0

Vous avez trouvé la solution après avoir lu les commentaires dans ce How to add Three Level ListView in ExpandableListView in android cela doit être implémenté dans le ParentLevelAdapter dans la partie publique View getChildView.

@Override 
public View getChildView(int groupPosition, int childPosition, 
         boolean isLastChild, View convertView, ViewGroup parent) { 
    final CustomExpListView secondLevelExpListView = new CustomExpListView(this.mContext); 
    String parentNode = (String) getGroup(groupPosition); 
    secondLevelExpListView.setAdapter(new SecondLevelAdapter(this.mContext, mListData_SecondLevel_Map.get(parentNode), mListData_ThirdLevel_Map)); 
    secondLevelExpListView.setGroupIndicator(null); 

//newcode 
    secondLevelExpListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener(){ 
     @Override 
     public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,long id) 
     { String selectText = ((TextView) v).getText().toString(); 
      switch (selectText){ 
       case "ItemName you want to do something with": 
        //Actions you want to do when clicking this item 
        break; 
       case "ItemName2 you want to do something with": 
        //Actions you want to do when clicking this second item 
        break; 
       default: 
        //default actions on all other items 
     } 

      return false;} 
    }); 

    return secondLevelExpListView; 
}