在preferencemenu中设置SeekBarPreference而不使用对话框

问题描述:

我正在创建首选项菜单,并尝试在首选项菜单中显示seekbar而不是显示对话框。在preferencemenu中设置SeekBarPreference而不使用对话框

我必须通过一个新的XML布局文件和新的优先级,使之?
与创建对话框SeekBarPreference相比,它看起来工作太多了。

任何意见,技巧,代码剪辑或lenks将不胜感激。

你想要什么?是这样的:

enter image description here

编辑: 的PreferenceActivity从ListActivity延伸,从而偏好本质上是一个列表视图。您可以实现此功能是这样的:

  1. 创建PreferenceActivity,并在onCreate()方法:

    公共无效的onCreate(捆绑savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); addPreferencesFromResource(R.xml.pref);

    } 
    
      开始=“2”>
    1. 在“主”布局,确保有一个ListView,使您的preference.xml 文件将被链接到ListView控件。声明这样说:

    <ListView 
        android:id="@android:id/list" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" > 
    </ListView> 
    
    <SeekBar 
        android:id="@+id/seekBar1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" /> 
    

    注为ListView的ID必须是:@android:id/list

    +0

    嗨,这正是我想要使。 – Bjorn