-1

It got me wondering on how to implement an "onChildChildClickListener" into this three level expandable list view after answering the question of how to populate three level expandable list view (Populate different arrays in third layer of expandableListView).

How does one implement the third level being Clickable?

Example code by BKN is published on githube here: https://github.com/ngocchung/ThreeLevelExpListView

Does anybody have an idea? Help would be gladly appreciated as I would like to implement this into an showcase app as a part of my Masterthesis.

jom
  • 11
  • 4

1 Answers1

0

Found the solution after reading the comments in this How to add Three Level ListView in ExpandableListView in android this needs to be implemented in the ParentLevelAdapter in the public View getChildView part.

@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;
}
jom
  • 11
  • 4