我有一个带有自定义适配器的Expandable Listview。每个父级都有一个Textview和一个开关控件。可扩展视图无效

时间:2015-06-10 06:24:44

标签: android expandablelistview

@Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        String headerTitle = (String) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflater layoutInflater = (LayoutInflater) this.context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = layoutInflater.inflate(R.layout.list_group, null);
        }
        //Switch switch1 = (Switch) convertView.findViewById(R.id.switch1);
        TextView lblHeader = (TextView) convertView
                .findViewById(R.id.categorytv);
        lblHeader.setTypeface(null, Typeface.BOLD);
        lblHeader.setText(headerTitle);


        return convertView;
    }

1 个答案:

答案 0 :(得分:0)

经过长时间的研究,我能够弄清楚这是已经解决的解决方案。

对于Switch

    <Switch
    android:id="@+id/switch1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusable="false"/>

所以在此之后我的可扩展列表视图开始按预期工作。

相关问题