Highlight for selected item in expandable list

后端 未结 11 2099
攒了一身酷
攒了一身酷 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:41

    expListView.setOnChildClickListener(new OnChildClickListener() {
    
            @Override
            public boolean onChildClick( ExpandableListView parent, View v,
                                         int groupPosition, int childPosition,
                                         long id) {
    
    
    
                for (int i = 1; i < expListView.getChildCount(); i++) {
                    View child = (View) expListView.getChildAt(i);
                    child.setBackgroundColor(Color.BLACK);
                }
    
    
                if(childPosition==0){
                    initWebView("URL");
    
                }
                if(childPosition==1) {
                    initWebView("URL");
    
                }
                if(childPosition==2) {
    
                    initWebView("URL");
    
                }
                if(childPosition==3) {
                    initWebView("URL");
    
                }
                if(childPosition==4) {
                    initWebView("URL");
    
                }
                if(childPosition==5) {
                    initWebView("URL");
                }
    
                v.setBackgroundColor(Color.GRAY);
    
    
                expListView.setVisibility(View.GONE);
                webView.setVisibility(View.VISIBLE);
                return false;
            }
        });
    }
    

提交回复
热议问题