| 3 | 1/1 | 返回列表 |
| 查看: 450 | 回復(fù): 2 | |||
張小販123銀蟲(chóng) (小有名氣)
|
[求助]
懂得進(jìn)來(lái)看看 金幣可以再商量么 哈哈
|
|
3,PreferenceActivityTest: package com.example.activity01; import java.util.List; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.app.Activity; import android.app.ExpandableListActivity; import android.app.LauncherActivity; import android.content.Intent; import android.view.Gravity; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.ArrayAdapter; import android.widget.BaseExpandableListAdapter; import android.widget.Button; import android.widget.ExpandableListAdapter; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; public class PreferenceActivityTest extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if(hasHeaders()){ Button button=new Button(this); button.setText("設(shè)置操作" ;setListFooter(button); } } @Override public void onBuildHeaders(List<Header> target) { // TODO Auto-generated method stub loadHeadersFromResource(R.xml.preference_headers,target); } public static class Prefs1Fragment extends PreferenceFragment{ @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } } public static class Prefs2Fragment extends PreferenceFragment{ @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.display_prefs); } } } 除此之外,在res.xml下面 還有三個(gè)布局文件: 1,preference_headers,xml: <?xml version="1.0" encoding="utf-8"?> <Preference-headers xmlns:android="http://schemas.android.com/apk/res/android" > <header android:fragment="com.example.activity01.PreferenceActivityTest$Prefs1Fragment" android:icon="@drawable/ic_settings_applications" android:title="程序選項(xiàng)設(shè)置" android:summary="設(shè)置應(yīng)用的相關(guān)選項(xiàng)" /> <header android:fragment="com.example.activity01.PreferenceActivityTest$Prefs2Fragment" android:icon="@drawable/ic_settings_display" android:title="界面選項(xiàng)設(shè)置" android:summary="設(shè)置顯示界面的相關(guān)選項(xiàng)"> </header> </Preference-headers> 2.display_prefs.xml: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:title="背景燈光組"> <ListPreference android:key="light" android:title="燈光強(qiáng)度" android:summary="請(qǐng)選擇燈光強(qiáng)度" android:dialogTitle="請(qǐng)選擇燈光強(qiáng)度" /> </PreferenceCategory> <PreferenceCategory android:title="文字顯示組"> <SwitchPreference android:key="autoScroll" android:title="自動(dòng)滾屏" android:summaryOn="自動(dòng)滾屏:開(kāi)啟" android:summaryOff="自動(dòng)滾屏:關(guān)閉" android:defaultValue="true"/> </PreferenceCategory> </PreferenceScreen> 3,preferences.xml: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <RingtonePreference android:ringtoneType="all" android:title="設(shè)置鈴聲" android:summary="選擇鈴聲" android:key="ring_key" android:showSilent="true" /> <PreferenceCategory android:title="個(gè)人信息組"> <EditTextPreference android:key="name" android:title="填寫(xiě)用戶名" android:summary="填寫(xiě)您的用戶名" android:dialogTitle="您所使用的用戶名為:"/> <ListPreference android:key="gender" android:title="性別" android:summary="選擇您的性別" android:dialogTitle="ListPreference"/> </PreferenceCategory> <PreferenceCategory android:title="系統(tǒng)功能設(shè)置組"> <CheckBoxPreference android:key="autoSave" android:title="自動(dòng)保存進(jìn)度" android:summaryOn="自動(dòng)保存:開(kāi)啟" android:summaryOff="自動(dòng)保存:關(guān)閉" android:defaultValue="true"/> </PreferenceCategory > </PreferenceScreen> 我的這個(gè)程序編譯沒(méi)有報(bào)錯(cuò),但是安裝運(yùn)行之后如果點(diǎn)擊主界面的“設(shè)置程序參數(shù)”選項(xiàng),就會(huì)死機(jī),不知道為什么,希望各位高手指教。! |

木蟲(chóng) (正式寫(xiě)手)
專(zhuān)家顧問(wèn) (文壇精英)
![]() |
專(zhuān)家經(jīng)驗(yàn): +1654 |
| 3 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 311求調(diào)劑 +5 | 藍(lán)月亮亮 2026-03-30 | 5/250 |
|
|---|---|---|---|---|
|
[考研] 材料專(zhuān)碩調(diào)劑 +11 | 椰椰。 2026-03-29 | 11/550 |
|
|
[考研] 0703化學(xué) +14 | 妮妮ninicgb 2026-03-27 | 14/700 |
|
|
[考研] 085602 化學(xué)工程專(zhuān)碩 340分求調(diào)劑 +4 | qianbai11 2026-03-29 | 4/200 |
|
|
[考研] 352分-085602-一志愿985 +5 | 海納百川Ly 2026-03-29 | 5/250 |
|
|
[考研] 085600,專(zhuān)業(yè)課化工原理,321分求調(diào)劑 +5 | 大饞小子 2026-03-28 | 5/250 |
|
|
[考研] 0703化學(xué)調(diào)劑,求導(dǎo)師收 +9 | 天天好運(yùn)來(lái)上岸?/a> 2026-03-24 | 10/500 |
|
|
[考研] 083000學(xué)碩274求調(diào)劑 +8 | Li李魚(yú) 2026-03-26 | 8/400 |
|
|
[考研] 食品工程專(zhuān)碩一志愿中海洋309求調(diào)劑 +4 | 小張zxy張 2026-03-26 | 8/400 |
|
|
[考研]
|
y7czhao 2026-03-26 | 10/500 |
|
|
[考研] 266分,求材料冶金能源化工等調(diào)劑 +7 | 哇呼哼呼哼 2026-03-27 | 9/450 |
|
|
[考研] 286求調(diào)劑 +12 | PolarBear11 2026-03-26 | 12/600 |
|
|
[考研] 086000調(diào)劑 +3 | 7901117076 2026-03-26 | 3/150 |
|
|
[考研] 272求調(diào)劑 +7 | 腳滑的守法公民 2026-03-27 | 7/350 |
|
|
[考研] 298調(diào)劑 +3 | jiyingjie123 2026-03-27 | 3/150 |
|
|
[考研] 315調(diào)劑 +4 | 0860求調(diào)劑 2026-03-26 | 5/250 |
|
|
[考研] 化學(xué)調(diào)劑一志愿上海交通大學(xué)336分-本科上海211 +4 | 小魚(yú)愛(ài)有機(jī) 2026-03-25 | 4/200 |
|
|
[考研] 086003食品工程求調(diào)劑 +6 | 淼淼111 2026-03-24 | 6/300 |
|
|
[考研] 340求調(diào)劑 +5 | 話梅糖111 2026-03-24 | 5/250 |
|
|
[考研] 344求調(diào)劑 +3 | desto 2026-03-24 | 3/150 |
|