[英]Is it possible to add a custom component to a Preference Activity in android?
有什么方法可以在首選項活動中添加自定義組件以更改設置的值?
您可以添加任何擴展android.app.Preference的自定義組件
或者,如果它應該是View-創建一個布局,但是您必須在PreferenceScreen的布局中包含一個帶有android.R.id.list的ListView。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_color" >
<YourCustomComponentView
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/view"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
在添加任何首選項之前,只需setContentView()即可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.