| 3 | 1/1 | 返回列表 |
| 查看: 453 | 回復(fù): 2 | |||
張小販123銀蟲 (小有名氣)
|
[求助]
懂得進(jìn)來看看 金幣可以再商量么 哈哈
|
|
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)滾屏:開啟" 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="填寫用戶名" android:summary="填寫您的用戶名" 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)保存:開啟" android:summaryOff="自動(dòng)保存:關(guān)閉" android:defaultValue="true"/> </PreferenceCategory > </PreferenceScreen> 我的這個(gè)程序編譯沒有報(bào)錯(cuò),但是安裝運(yùn)行之后如果點(diǎn)擊主界面的“設(shè)置程序參數(shù)”選項(xiàng),就會(huì)死機(jī),不知道為什么,希望各位高手指教。! |

木蟲 (正式寫手)
專家顧問 (文壇精英)
![]() |
專家經(jīng)驗(yàn): +1654 |
| 3 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 一志愿華東師范大學(xué)有機(jī)化學(xué)專業(yè),初試351分,復(fù)試被刷求調(diào)劑! +7 | 真名有冰 2026-03-29 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 11408總分309,一志愿東南大學(xué)求調(diào)劑,不挑專業(yè) +5 | 天賦帶到THU 2026-03-29 | 6/300 |
|
|
[考研] 281求調(diào)劑 +5 | 亞克西good 2026-03-26 | 7/350 |
|
|
[考研] 一志愿南昌大學(xué)324求調(diào)劑 +9 | hanamiko 2026-03-27 | 9/450 |
|
|
[考研] 311求調(diào)劑 +7 | 藍(lán)月亮亮 2026-03-30 | 7/350 |
|
|
[考研] 材料學(xué)碩333求調(diào)劑 +14 | 北道巷 2026-03-24 | 14/700 |
|
|
[考研] 085701求調(diào)劑初試286分 +5 | secret0328 2026-03-28 | 5/250 |
|
|
[考研] 一志愿211,335分,0856,求調(diào)劑院校和導(dǎo)師 +7 | 傾____蕭 2026-03-27 | 8/400 |
|
|
[考研] 289求調(diào)劑 +5 | BrightLL 2026-03-29 | 5/250 |
|
|
[考研] 340求調(diào)劑 +6 | Amber00 2026-03-26 | 6/300 |
|
|
[考研] 305求調(diào)劑 +8 | RuiFairyrui 2026-03-28 | 8/400 |
|
|
[考研] 316求調(diào)劑 +7 | 江辭666 2026-03-26 | 7/350 |
|
|
[考研] 壓國(guó)家一區(qū)線,求導(dǎo)師收留,有恩必謝! +7 | 迷人的哈哈 2026-03-28 | 7/350 |
|
|
[考研] 299求調(diào)劑 +7 | 嗯嗯嗯嗯2 2026-03-27 | 7/350 |
|
|
[考研] 308求調(diào)劑 +7 | 墨墨漠 2026-03-27 | 7/350 |
|
|
[考研] 求調(diào)劑推薦 材料 304 +15 | 荷包蛋hyj 2026-03-26 | 15/750 |
|
|
[考研] 070300化學(xué)求調(diào)劑 +4 | 起個(gè)名咋這么難 2026-03-27 | 4/200 |
|
|
[考研] 324求調(diào)劑 +5 | hanamiko 2026-03-26 | 5/250 |
|
|
[考研] 打過很多競(jìng)賽,085406控制工程300分,求調(diào)劑 +3 | askeladz 2026-03-26 | 3/150 |
|
|
[考研] 302求調(diào)劑 +4 | 錦衣衛(wèi)藤椒 2026-03-25 | 4/200 |
|