无法使用PreferenceScreen正确实现SwitchPreference并在Android的操作栏中显示switch
我正在设置我的应用程序 我想这样显示设置 我对此有偏好无法使用PreferenceScreen正确实现SwitchPreference并在Android的操作栏中显示switch,android,xml,android-layout,android-intent,android-preferences,Android,Xml,Android Layout,Android Intent,Android Preferences,我正在设置我的应用程序 我想这样显示设置 我对此有偏好 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <SwitchPreference android:key="isCallerIdOn" android:title="Caller ID" > <intent android:action=".activity.CallerI
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<SwitchPreference
android:key="isCallerIdOn"
android:title="Caller ID" >
<intent android:action=".activity.CallerIdSettings" />
</SwitchPreference>
单击呼叫者Id将打开新屏幕
那是
哪一个像xml
代码是
switch_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Switch
android:id="@+id/switchForActionBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
及
switch_menu.xml是
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/myswitch"
android:actionLayout="@layout/switch_layout"
android:showAsAction="always"
android:title=""/>
现在我陷入的困境是:
1.在通过发送意图单击“callerId”打开的第二个屏幕中,它不显示操作栏
2.我需要显示带有按钮的操作栏,无论它是打开还是关闭,就像在Wi-Fi中一样
为此,我在菜单中设置了开关,它继承了包含上述开关的布局
我无法将该开关与代码链接
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/myswitch"
android:actionLayout="@layout/switch_layout"
android:showAsAction="always"
android:title=""/>