Android:可扩展列表视图中的可绘制设置(重复)

Android:可扩展列表视图中的可绘制设置(重复),android,expandablelistview,Android,Expandablelistview,在我的应用程序中,我有一个可展开列表视图,我想用另一个可展开列表视图更改可展开列表视图上的组箭头,但没有显示任何内容。这是我的代码,我如何修复它 <ExpandableListView android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:i

在我的应用程序中,我有一个可展开列表视图,我想用另一个可展开列表视图更改可展开列表视图上的组箭头,但没有显示任何内容。这是我的代码,我如何修复它

<ExpandableListView
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/expandableListView"
            android:groupIndicator="@drawable/group_indicator"/>
有人帮我吗?我真的需要它

编辑:


创建自定义适配器,创建一个类并扩展BaseExpandableListAdapter 40分钟前你问了这个问题,40分钟后再问,为什么不等待原始问题的答案?@pskink:因为我真的需要它,我没有时间。@Shayanpourvatan:我有这个类。你想更改复选框视图吗?你指的是哪支箭?
<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_empty="true" android:drawable="@drawable/arrow_up"></item>
        <item android:state_expanded="true" android:drawable="@drawable/arrow_down"></item>
        <item android:drawable="@drawable/arrow_up"></item>
</selector>
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final ParentActivity thisActivity = this;
        setContentView(R.layout.backup_list);
        ActionBar actionBar = getSherlock().getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        // get the listview
        expListView = (ExpandableListView) findViewById(R.id.expandableListView);
        expListView.setIndicatorBounds(width - GetDipsFromPixel(50), width - GetDipsFromPixel(10));
....
}



 public int GetDipsFromPixel(float pixels)
    {
        // Get the screen's density scale
        final float scale = getResources().getDisplayMetrics().density;
        // Convert the dps to pixels, based on density scale
        return (int) (pixels * scale + 0.5f);
    }
public class ExpandableListAdapter extends BaseExpandableListAdapter {
    private ParentActivity parentActivity;
    private List<SelectableEntity> _listDataHeader; // header titles
    // child data in format of header title, child title
    private HashMap<String, List<SelectableEntity>> _listDataChild;

    public ExpandableListAdapter(ParentActivity context, List<SelectableEntity> listDataHeader, HashMap<String, List<SelectableEntity>> listChildData) {
        this.parentActivity = context;
        this._listDataHeader = listDataHeader;
        this._listDataChild = listChildData;
    }

    @Override
    public SelectableEntity getChild(int groupPosition, int childPosititon) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition).title).get(childPosititon);
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) this.parentActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(R.layout.list_item2, null);
        }

        final SelectableEntity child = getChild(groupPosition, childPosition);

        TextView txtListChild = (TextView) convertView.findViewById(R.id.lblListItem);
        txtListChild.setText(child.title);

        CheckBox childBox = (CheckBox) convertView.findViewById(R.id.childcheckbox);
        childBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                parentActivity.checkParent(child, ((CheckBox) view).isChecked());
            }
        });
        childBox.setChecked(child.state);

        return convertView;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition).title)
                .size();
    }

    @Override
    public SelectableEntity getGroup(int groupPosition) {
        return this._listDataHeader.get(groupPosition);
    }

    @Override
    public int getGroupCount() {
        return this._listDataHeader.size();
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        SelectableEntity header = getGroup(groupPosition);
        final LayoutInflater infalInflater = (LayoutInflater) this.parentActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if (convertView == null) convertView = infalInflater.inflate(R.layout.list_group, null);

        TextView lblListHeader = (TextView) convertView.findViewById(R.id.lblListHeader);
        lblListHeader.setTypeface(null, Typeface.BOLD);
        lblListHeader.setText(header.title);

        final TextView textView = (TextView) convertView.findViewById(R.id.lblListHeader);
        CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.parentcheckbox);
        checkBox.setChecked(header.state);
        checkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                parentActivity.checkAll(textView.getText().toString(), ((CheckBox) view).isChecked());
            }
        }
        );

        return convertView;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
}