我得到了以下問題:在我的Android應用程序中,我使用表來顯示一些信息。該信息還包含顯示爲複選框的2個布爾值。當表格被加載時,複選框按照他們應該的方式工作,但只要我改變界面方向,即使數據值爲假,也會檢查兩個複選框。Android - 奇怪的複選框行爲
表的定義是這樣的:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/table_properties"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
/>
和一個布爾值列在表:
<TableRow
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_jobprop_name"
style="@style/text_list_black"
android:layout_height="fill_parent"
android:textSize="12dp"
android:padding="3dp"
android:singleLine="false"
android:gravity="center_vertical"
android:background="@color/table_property_name_background"
android:layout_weight="0.7"
android:layout_width="0dp"
/>
<LinearLayout
android:layout_height="wrap_content"
android:gravity="left"
android:layout_marginRight="5dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:layout_width="0dp"
android:background="@color/white">
<CheckBox
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/chckbox_jobprop_value"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:clickable="false"
android:layout_marginLeft="10dp"
/>
</LinearLayout>
</TableRow>
而且在我調用一個函數活動的onCreate方法是將所有的表格的值。我知道每次更改界面方向時都會調用此函數,但我調試了它並且數據值不會更改。
任何提示,想法,什麼?
謝謝。
謝謝,那工作。 – Pathos 2012-04-03 07:42:12
千謝謝,這也爲我解決了:)我聽到其他地方onRestoreInstanceState也可能工作。仍然 - 奇怪的行爲,很難搜索:/ – Groxx 2013-01-10 06:05:31