每次我选中按钮时,我都会为新的复选框增加布局, 如何保存这些复选框的状态和(键,值), 当我再次膨胀它检索这些状态时,共享偏好可以做到这一点,或者我应该使用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>
答案 0 :(得分:0)
使用In [31]: s2['col1'].apply(lambda x: s2_dic[x] if pd.notnull(x) else x)
Out[31]:
0 NaN
1 1
2 2
3 3
4 3
5 3
Name: col1, dtype: float64
保存并检索SharedPrefernces
州
CheckBox
请注意,如果您未在SharedPrefernces sharedPrefernces = getSharedPreferences(<SharedPreferencesName>, <Mode>);
CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox);
boolean checkBoxState = checkBox.getChecked();
// Save state in SharedPreferences
SharedPrefernces.Editor editor = sharedPrefernces.edit();
editor.putBoolean(<Key>, state).commit();
// Retrieve CheckBox state from SharedPreferences
boolean checkBoxState = sharedPrefernces.getBoolean(<Key>, <DefaultValue>);
getSharedPreferences