[英]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.