First look at the effect:
1
2
3
4
Androidmanifest. xml
<? XML version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: Android = "http://schemas.android.com/apk/res/android" package = "com. NJ. demo "Android: versioncode =" 1 "Android: versionname =" 1.0 "> <application Android: icon =" @ drawable/icon "> <activity Android: configchanges = "keyboardhidden | orientation" Android: Label = "Settings and help" Android: Name = ". settingactivity "Android: theme =" @ style/Default "> <intent-filter> <action Android: Name =" android. intent. action. main "/> <category Android: Name =" android. intent. category. launcher "/> </intent-filter> </activity> <activity Android: alwaysretaintaskstate =" true "Android: configchanges =" keyboardhidden | orientation "Android: Name = ". skinactivity "Android: theme =" @ Android: style/theme. notitlebar "> </activity> <activity Android: Name = ". trafficstatactivity "Android: theme =" @ Android: style/theme. notitlebar "> </activity> <activity Android: Name = ". friendinfoactivity "Android: theme =" @ Android: style/theme. notitlebar "Android: windowsoftinputmode =" adjustunspecified | statehidden "> </activity> </Application> </manifest>
Settingactivity. Java
Package COM. NJ. demo; import android. OS. bundle; import android. preference. preferenceactivity;/*** set **/public class settingactivity extends preferenceactivity {protected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // load the preferences from an XML resource addpreferencesfromresource (R. XML. setting_preference );}}
Friendinfoactivity. Java
Package COM. NJ. demo; import android. app. activity; import android. OS. bundle; import android. view. view; import android. view. view. onclicklistener; import android. view. inputmethod. inputmethodmanager; import android. widget. edittext; import android. widget. linearlayout; import android. widget. textview; import android. widget. toast;/*** friend information **/public class friendinfoactivity extends activity {private textview comment; private edittext mcommentedittext; private Boolean mbcommenteditable; private inputmethodmanager mkeyborad; private string mcommenttmpstring; private linearlayout mqzone; private linearlayout mmailayout; private linearlayout mchat; protected void oncreate (bundle savedinstancestate) {// todo auto-generated method stubsuper. oncreate (savedinstancestate); setcontentview (r.layout.info _ friend); Init ();} private void Init () {mchangecommenttextview = (textview) findviewbyid (R. id. change_comment); mchangecommenttextview. setonclicklistener (New onclicklistener () {public void onclick (view v) {// todo auto-generated method stubswitchcommentstate () ;}); mcommentedittext = (edittext) findviewbyid (R. id. edit_comment); Comment = false; mkeyborad = (inputmethodmanager) getsystemservice (input_method_service); view view1 = findviewbyid (r.id.info _ qzone_mail); mqzone = (linearlayout) Comment. id. qzone); mqzone. setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {// todo auto-generated method stubtoast. maketext (friendinfoactivity. this, "you press Qzone", toast. length_short ). show () ;}}); mmailayout = (linearlayout) view1.findviewbyid (R. id. mail); mmailayout. setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {// todo auto-generated method stubtoast. maketext (friendinfoactivity. this, "you press main", toast. length_short ). show () ;}}); mchat = (linearlayout) view1.findviewbyid (R. id. chat); mchat. setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {// todo auto-generated method stubtoast. maketext (friendinfoactivity. this, "you press chat", toast. length_short ). show () ;}}) ;}private void switchcommentstate () {If (mbcommenteditable) {mbcommenteditable = false; mcommentedittext. setfocusableintouchmode (false); mcommentedittext. setfocusable (false); mchangecommenttextview. settext ("modify"); Boolean ret = mkeyborad. hidesoftinputfromwindow (mcommentedittext. getwindowtoken (), 0); If (ret = false) {mcommentedittext. settext (mcommenttmpstring) ;}} else {mbcommenteditable = true; mcommentedittext. setfocusableintouchmode (true); mcommentedittext. setfocusable (true); mchangecommenttextview. settext ("OK"); mkeyborad. showsoftinput (mcommentedittext, 0); mcommenttmpstring = mcommentedittext. gettext (). tostring ();}}}
Skinactivity. Java
Package COM. NJ. demo; import Java. util. arraylist; import Java. util. list; import COM. NJ. demo. adapter. skinlistadapter; import COM. NJ. demo. adapter. skinlistitemdata; import android. app. activity; import android. OS. bundle; import android. util. log; import android. view. view; import android. widget. adapterview; import android. widget. listview; import android. widget. textview; import android. widget. adapterview. onitemclickli Stener; import android. widget. adapterview. onitemselectedlistener;/*** skin change ***/public class skinactivity extends activity {private final int skiniconid [] = {R. drawable. skinpic_blue, R. drawable. skinpic_green, R. drawable. skinpic_pink, R. drawable. skinpic_snow}; private final string text [] = {"Blue Water quiet overflow", "Green fog morning light", "pink flower", "silver wrapped"}; private final int uncheckicon = R. drawable. themeradio; private listview mlistview; PR Ivate skinlistadapter mskinlistadapter; private textview mtitletextview; protected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // load the preferences from an XML resource setcontentview (R. layout. skin_main_layout); Init ();} private void Init () {mlistview = (listview) findviewbyid (R. id. themelist); mskinlistadapter = new skinlistadapter (this, getitemlist (); mlistview. s Etadapter (mskinlistadapter); mlistview. setonitemclicklistener (New onitemclicklistener () {@ overridepublic void onitemclick (adapterview <?> Parent, view, int position, long ID) {// todo auto-generated method stubmskinlistadapter. setselect (position); mtitletextview. setbackgroundresource (skiniconid [position]) ;}}); mtitletextview = (textview) findviewbyid (R. id. skintitle);} private list <skinlistitemdata> getitemlist () {list <skinlistitemdata> List = new arraylist <skinlistitemdata> (); For (INT I = 0; I <4; I ++) {skinlistitemdata DATA = new skinlistitemdata (); data. mimageviewleftid = skiniconid [I]; data. mtextview = text [I]; data. mimageviewrightid = uncheckicon; List. add (data) ;}return list ;}}
Trafficstatactivity. Java
Package COM. NJ. demo; import android. app. activity; import android. OS. bundle; import android. view. view; import android. widget. textview;/*** Traffic Statistics */public class trafficstatactivity extends activity {private textview detail; private textview mtextviewtotalsendtextview; private textview detail; protected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // load the preferences from an XML resource setcontentview (R. layout. act_set_trafficstat); Init ();} private void Init () {view layout1 = findviewbyid (R. id. trafic_today_tbl); mtextviewbasesendtextview = (textview) layout1.findviewbyid (R. id. base_send_trafic); mtextviewbaserecvtextview = (textview) layout1.findviewbyid (R. id. base_recv_trafic); mtextviewtotalsendtextview = (textview) layout1.findviewbyid (R. id. total_send_trafic); mtextviewtotalrecvtextview = (textview) layout1.findviewbyid (R. id. total_recv_trafic); mtextviewbasesendtextview. settext ("14 KB"); mtextviewbaserecvtextview. settext ("3 kb"); mtextviewtotalsendtextview. settext ("14 KB"); mtextviewtotalrecvtextview. settext ("3 kb ");}}
Resource: http://download.csdn.net/detail/niejing654092427/4500972
Ii. Custom preferenceactivity
Resource: http://download.csdn.net/detail/niejing654092427/5209112