2017-09-11 13 views
-1

3レベルの展開可能リストビュー(Populate different arrays in third layer of expandableListView)を設定する方法の質問に答えた後、この3レベルの展開可能リストビューに "onChildChildClickListener"を実装する方法が不思議です。"onChildChildClick" 3レベルの展開可能リストビュー

クリック可能な第3レベルはどのように実装されますか? BKNによって

例のコードはここgithubeに公開されています。 https://github.com/ngocchung/ThreeLevelExpListView

誰のアイデアを持っていますか? 私の熟練の一部としてショーケースアプリにこれを実装したいので、喜んで感謝します。

答えて

0

How to add Three Level ListView in ExpandableListView in android のコメントを読んで解決策を見つけました。これは、パブリックビューのgetChildViewパートのParentLevelAdapterに実装する必要があります。

@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; 
} 
関連する問題