How can i disable Expandable Listview icon from it's header in android?

后端 未结 2 1176
南笙
南笙 2021-01-28 21:03

I created an ExpandableListView in android. I have some categories which have some more sub-categories. While other do not have sub-categories. How can I remove the

2条回答
  •  盖世英雄少女心
    2021-01-28 21:29

    First of all , remove the default icon of expandable listview

    
    

    And than in your adapter of Expandable listview in getGroupView method use following code for it

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
                             View convertView, ViewGroup parent) {
        String headerTitle = (String) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) this._context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(R.layout.YOUR_LIST_GROUP_XML, null);
        }
    
        TextView header_tv = (TextView) convertView.findViewById(R.id.list_header_tv);
        ImageView arrow_iv =(ImageView) convertView.findViewById(R.id.arrow_iv);
    
    
        header_tv.setText(headerTitle);
    
        Boolean check = false;
    
        try {
    
    
            YOUR_HAS_MAP_LIST.get(this._listDataHeader.get(groupPosition))
                    .get(0);
        }
        catch (Exception ex)
        {
            check = true;
            ex.printStackTrace();
        }
        if(check)
        {
            arrow_iv.setVisibility(View.INVISIBLE);
        }
    
        if(isExpanded)
        {
            arrow_iv.setImageResource(R.drawable.UP_ARROW);
        }
        else
        {
            arrow_iv.setImageResource(R.drawable.DOWN_ARROW);
        }
    
        return convertView;
    }
    

提交回复
热议问题