【问题标题】:Android: Preference values to textview from preferences.xmlAndroid:从preferences.xml 到textview 的偏好值
【发布时间】:2011-09-12 07:09:28
【问题描述】:

我在 xml/preferences.xml 中有一个偏好 xml:

    <EditTextPreference
    android:key="welcome_message"
    android:title="Welcome message" 
    android:summary="Default welcome message"
    android:dialogTitle="Tervetuloa-viesti"
    android:dialogMessage="Input"    
    android:defaultValue="Default message" />

我知道如何通过代码从首选项中获取welcome_message,但我可以在XML 中这样做吗:

    <TextView android:id="@+id/txt" android:layout_width="wrap_content" android:text="(INCLUDE welcome_message HERE)" android:layout_height="wrap_content" />

在我的 main.xml 中,如果是这样,如何?谢谢。

【问题讨论】:

  • 你不能通过 xml 来做。

标签: android xml preferences


【解决方案1】:

据我所知,您不能直接从 xml 布局中引用偏好值。

【讨论】:

  • 谢谢。所以我不得不使用另一种方式。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-17
  • 1970-01-01
  • 1970-01-01
  • 2014-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多