私はデフォルトの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" />
スイッチをクリックしたときにリスナーコードを共有します。 –
ididは、リスナーが右にトグルを追加した後に、グループ指示として右側にトグルを追加した後でチェックして見つけただけです。リスト表示が展開されません。 – Niraj
参照してください私はarcheiveしたい画像を追加しました。 – Niraj