Highlight for selected item in expandable list

后端 未结 11 2094
攒了一身酷
攒了一身酷 2021-01-31 21:25

I have a layout where I have an expandable list in a fragment on the left and a details fragment on the right. This all works fine.

Now I would like to indicate what

11条回答
  •  心在旅途
    2021-01-31 21:39

    After spending 3-4 hours it is made it its so simple no need to create extra XML files just check if the group item is expanded if yes then select color and in else statement make them as they are ....

    @Override
    //in this method you must set the text to see the parent/group on the list
    public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {
    
        if (view == null) {
            view = inflater.inflate(R.layout.list_item_parent, viewGroup,false);
        }
    
        if(b){
            view.setBackgroundResource(R.color.waterblue);
        }else{
            view.setBackgroundColor(color.transparent);
        }
    
    
        //return the entire view
        return view;
    }
    

提交回复
热议问题