開源中國Android版學習筆記(一) Preferences.xml的使用

來源:互聯網
上載者:User

        終於是把開源中國的代碼拷到了ADT中,看到數不清的源碼,實在是頭暈,於是決定對每段代碼進行自己的注釋,以便協助自己更好的學習Android。

        看到一大堆的尾碼xml的檔案,決定還是從簡到繁,於是這第一篇文章就寫給res\Preferences.xml。

        對照著手機的開源中國,這段代碼寫的是系統設定。首先看到的是一對<Preferencescreen>標籤,裡面是四對<PreferenceCategory>標籤。<Preferencescreen>標籤作用是設定介面顯示。<PreferenceCategory>標籤可以翻譯為喜好設定。下面以第一個<PreferenceCategory>標籤為例來介紹:

<PreferenceCategory     android:layout="@layout/preference_category"     android:title="帳號管理">    <Preference         android:layout="@layout/preference"         android:title="使用者登入"         android:key="account" />    <Preference         android:layout="@layout/preference"         android:title="我的資料"         android:key="myinfo"         android:summary="我的資訊、收藏、粉絲..."/>    </PreferenceCategory>

再跟圖片作對比:

android:title即為設定標題。
裡面內建了兩個<Preference>標籤,作為二級介面。
android:key相當於id。
android:summary可以作為裡面的小字型。
其實這段代碼功能就是這個頁面,在java原始碼中調用該xml,就可以產生相應的preference介面。(目前還沒找到該java源檔案,待以後找到再補上)
想知道更多關於</PreferenceCategory>應用的話進http://blog.csdn.net/flowingflying/article/details/6671548,這裡面有很詳細的介紹。

Ok,未完待續。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.