0
我想向可擴展列表的父視圖添加一個按鈕。這是我對parentview的佈局。我需要一個可擴展列表的父視圖中的按鈕
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/explist_indicator"
android:layout_width="25dp"
android:layout_height="match_parent"
android:layout_weight=".25"
android:src="@drawable/expander_group" />
<TextView
android:id="@+id/contacts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:paddingLeft="20dp"
android:text="@string/contacts"
android:textSize="28dp" >
</TextView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:background="@drawable/plus"
android:text="Button" />
</LinearLayout>
我將按鈕添加到Java類像正常的,卻得到了一個空指針異常,當我嘗試添加一個監聽器。我添加此按鈕來選擇/取消選擇特定父級的所有子級。任何幫助都會很棒。
您還需要發佈一些代碼 - 以及您的LogCat。 – kaspermoerch