代码之家  ›  专栏  ›  技术社区  ›  Wonko the Sane

preferences.xml中的PreferenceScreen意图

  •  2
  • Wonko the Sane  · 技术社区  · 14 年前

    有没有人知道一个很好的例子来说明如何从首选屏幕启动意图?

        <PreferenceScreen
            android:key="preference_some_new_layout"
            android:title="@string/pref_some_title">
    
                <intent android:action="????" /> 
    
        </PreferenceScreen>
    

    我想显示一个自定义的线性布局,允许我设置一些半复杂的首选项。

    最好的办法是什么?

    谢谢,

    1 回复  |  直到 14 年前
        1
  •  5
  •   Bryan Denny    14 年前

    我以前使用过自定义对话框作为首选项。这是你需要的吗? Here is an example from my open source app.

    以及 here is the XML to add the preference to a PreferenceScreen .

    <net.mandaria.tippytipper.preferences.DecimalPreference
                            android:key="exclude_tax"
                    android:title="Tax Rate to Exclude"
                    android:summary="The tax rate to exclude when calculating tip"
                    android:dialogMessage="Tax Rate"
                    android:defaultValue="0"
                    android:dependency="enable_exclude_tax_rate"
                    />
    

    这将使您在DialogPreference中生成复杂的首选项(如果不需要对话框,您可能可以将其替换掉,因为我从未尝试过,所以必须由其他人为您填写)如下所示:

    alt text

    推荐文章