2017-08-18 4 views
0

私はデフォルトのgroupIndicatorといくつかの子項目でexpandablelistviewを含むアプリを持っています。グループヘッダーの右側にトグルボタンを追加したいのですが、そのリストビューを展開すると展開されません。 Plsはこのporblemから私を助けます。expandablelistviewのgroup indicatiorにボタンを追加してもリストは展開されませんか?

コード: -

@Override 
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { 
    WhiteListModel model = whiteListStorage.get(groupPosition); 
    if (convertView == null) { 
     LayoutInflater infalInflater = (LayoutInflater) this._context 
       .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     convertView = infalInflater.inflate(R.layout.white_list_group_header, null); 
    } 
    TextView t = (TextView) convertView.findViewById(R.id.lblListHeader); 
    t.setTypeface(null, Typeface.BOLD); 
    t.setText(model.getName()); 

    return convertView; 
} 

主活性XML: -

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:background="#f4f4f4" > 

<ExpandableListView 
    android:id="@+id/lvExp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:choiceMode="singleChoice"/> 

グループヘッダXML: -

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:padding="12dp"> 


<TextView 
    android:id="@+id/lblListHeader" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft" 
    android:textColor="#000" 
    android:textSize="17dp" /> 

<android.support.v7.widget.SwitchCompat 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBaseline="@+id/lblListHeader" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="4dp" 
    android:checked="true" /> 

enter image description here

+0

スイッチをクリックしたときにリスナーコードを共有します。 –

+0

ididは、リスナーが右にトグルを追加した後に、グループ指示として右側にトグルを追加した後でチェックして見つけただけです。リスト表示が展開されません。 – Niraj

+0

参照してください私はarcheiveしたい画像を追加しました。 – Niraj

答えて

0

switchcompatがチェックされているときにswitchCompatのリスナメソッドでExpandableListView.expandGroup(pos)を使用してグループを展開し、未チェックのときにExpandableListView.collapseGroup(pos)を呼び出します。

+0

いいえ、私はスイッチのリスナーに私の問題は、グループヘッダーの左側にデフォルトの表示とセンターcontaingグループのヘッダーが含まれている右に私はトグルを追加していることを拡張したくないです。私はlistviewをクリックすると、すべてを行った後、それは拡大されていません。 – Niraj

+0

switchCompatにandroid:focusable = "false"を追加してみてください。 –

+0

はいsagarは動作していません....すばらしいおかげで – Niraj

関連する問題