zoukankan      html  css  js  c++  java
  • howtoaddabuttontopreferencescreen 自定义view

    引用:http://stackoverflow.com/questions/2697233/how-to-add-a-button-to-preferencescreen

    There is another solution for customizing the appearance of the preferences.

    Design a normal XML layout with buttons or whatever you want to add to the standard preferences. Include aListView in your layout and give it the ID @android:id/list.

    Let's say we call the layout file res/layout/main.xml. It could look something like this:

    <?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"><Buttonandroid:text="This is a button on top of all preferences."android:layout_width="wrap_content"android:layout_height="wrap_content"/><ListViewandroid:id="@android:id/list"android:layout_width="fill_parent"android:layout_height="fill_parent"/></LinearLayout>

    In your PreferenceActivity, add these two lines to your onCreate:

    addPreferencesFromResource(R.xml.preferences);
    setContentView(R.layout.main);

    The ListView in your layout will then be replaced by the preferences defined the usual way inres/xml/preferences.xml.

  • 相关阅读:
    [转]mysql视图学习总结
    [转]mysql索引详解
    mysql索引的操作
    [转]mysql的约束
    mysql表的操作
    【转】mysql的数据类型
    java泛型
    java 8新特性
    Dubbo有意思的特性介绍
    dubbo + zookeeper
  • 原文地址:https://www.cnblogs.com/sode/p/2879789.html
Copyright © 2011-2022 走看看