[英]how can i set Enabled false after one click on my card view here using shared preferences
[英]Using a String in Stored in Shared Preferences in Card View Layout
我想使用存儲在卡視圖中“共享首選項”中的字符串值。 我知道很可能無法將其直接添加到XML布局中。 如果是這種情況,將這個字符串添加到下面XML布局中現有TextView的java是什么。
卡視圖的XML布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- A CardView that contains 2 TextViews -->
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view_results"
android:layout_width="match_parent"
android:layout_height="375dp"
android:layout_gravity="center"
android:layout_marginBottom="25dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="25dp"
card_view:cardBackgroundColor="#FFFFFF"
card_view:cardCornerRadius="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginTop="20dp"
android:text="@string/heading"
android:textColor="#050505"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="@+id/value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title_text_body"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:padding="10dp"
android:text="<String stored in Shared Preferences>"
android:textColor="#050505"
android:textSize="15sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
要顯示存儲在“共享首選項”中的字符串值,
使用setText(...)函數將其設置為您的TextView之一! :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.