我每次使用选项卡按钮时都会膨胀具有新复选框的布局,我如何保存这些复选框的状态和(键、值) ,当我再次膨胀时检索这些状态,共享首选项可以做到这一点,或者我应该这样做使用 SQLite 数据库?
这是我正在谈论的布局。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/checkBox"
style="?android:attr/starStyle"
android:layout_alignBottom="@+id/teamTextView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/teamTextView"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/LogoImageView"
android:layout_toLeftOf="@+id/checkBox"
android:layout_toStartOf="@+id/checkBox"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="2dp"
android:background="#d3d3d3" >
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/LogoImageView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>