Rwm

+ t Button -flWt Spinner WW Spinner setDrop

Down View Resource JfU^il it Kft+Krtft. iMlM'h Spinner R.array.gps ill R.array.map

Wim, value/array.xml K^aiftB.ta fift^:

<resources>

<!-- Used in View/setting.java --> <st ring-array name ="gps"> <item>5</item> <i i em>10</item>

< i tem>15</item> <item>30</i Lem> <item>60</item>

< i tem>12 0</i tem> </string-array>

<string array name="map"> <item>l</item> <item>2</item> < i t. em > 3 < / i t em> <item>4</item> <item>5</item> <item>6</i tem> </string-array>

</resources>

\'J&imtiLX fmww resources, gps # map, Fift^1}1

onCreate + setListensers S&liS«, fl^^lLiWittJ

private void setListensers() { Log.d(TAG, "set Listensers");

button setting submit. setOnClickListener (set.ting_submit) ; )

IJSftPJilWi setOnClickListener button setting submit .Iriftffii >J setting_submit, private Button.OnClickListener setting submit - new Button.OnClickListener() ( public void onClick(View v) { Log.d(TAG, "onClick new track.."); try {

String gps = (field setting_gps.getSelectedltem().toString()); String map (field_setting map level.getSelectedltem() .toString ());

if (gps.equals("") II map.equals("")) { Toast.makeText(Setting.this, getString(R.string.setting null), Toast.LENGTK_SHORT).show(); ) else {

storePrefs();

Toast.makeText(Setting.this, getString (R . string. set.t ing_ok) , Toast.LENGTH SHORT).show();

Intent intent new Intent (); i ntent.setClass(Sett ing.this, iTracks.class); startActivity(intent); J

Toast.makeText(Setting.this, getString(R.string.setting_fail), Toast.LENGTH SHORT).show();

^ Button.OnC lickListencrsetting submit. jffirfa'&iW,% onClick()//&, ffi onClick() , im getSelectedltem ftftj&tf ft* 1.1. iitff JBIttffl Toast fi^

UUKStfHM. KlJffi/flstorePrefsOÜtif^. storePrefsO'^fiftiW^I F:

n 13 M Android -^ Google Map ^^Af^ifeffl

//ftiftAai private void storePrefsO (

Log.d(TAG, "storePrefs setting infos");

SharedPreferences SharedProferences settings = getSharedPreferences(SETTING_INFOS, 0);

//ftmmpmnmi settings.edit()

-putSt ring (SETTING_GPS, field setting gps . getSelectedl t em () .toStringO) .putstring(SETTING MAP, field_settingmap level.getSelectedltem().toString()) .putInt(SETTING_GPS_POSITON, field setting gps.getSelectedltemPosition()) .putlnt(SETTING MAP POSITON, field_settingmap level.getSelectedltemPosition())

SharedPreferences settings, &SU WflJR- editO^/ft^&nJ i^liMffl SharedPreferences fill&• H-;

Mtiwrnmm.

£ oncreat +J0EW -tHfi restorePrefs, WWWa&M^fi: K&iSfttfjKiMfcK h,

// preferences 4" tfj !*J # private void restorePrefs() {

SharedPreferences settings = getSharedPreferences(SETTING INFOS, 0);

int setting gps p settings.getInt(SETTING GPS POSITON, 0) ;

int setting map level p settings.getInt(SETTING MAP POSITON, 0) ;

Log.d(TAG, "restorePreis: setting gps "+ setting_gps_p + ",setting_map level = " ♦ setting map level p);

if (setting gps p != 0 setting map level p != 0} I £ield_setting_gps.setSelection(set ting_gps_p) ; field_settmg_map_levei.setSelection(setting_map_level p); button setting submit.requestFocus(); lelse if(setting gps p != 0 ){

field setting_gps.setSelect ion(setting gps_p); field setting_map_level.requestFocus(); lelse if(setting map_level_p != 0){

field_setting_map_level.setSelection(setting map level_p); field settinggps.requestFocus(); lelse{

field setting_gps.requestFocus(); }

A SharedPreferences ' I' fill& J&0T ft ft ^J&i&ftWftX. JftJS

fm setSelection wn. «vw&wmMmbmt»

{¿Override public boolean onCreateOptionsMenu(Menu menu) ( super.onCreateOptionsMenu(menu);

menu.add(0, MENU MAIN, 0, R. string .menu_main) . setlcon ( R. drawable . icon) . setA.l phabeticShortcut ( 'M' ) ; menu.add(0, MENUNEW, 0, R.string.menu new) .setIcon (

P.. drawable . new track) . set. Alphabet icSftortcu t ( ' N' ) ; menu.add(0, MENUBACK, 0, R.string.menuback).setlcon{ H.drawable.back).setAlphabeticShortcut('E*); return true; 1

(¿Override public boolean onOptionsI temSelected (Menultem .tern) { Intent intent = new Intent (); switch (i tern.getltemld()) { case MENU NEW:

intent.setClass(Setting.this, NewTrack.class); s tar tActivity(intent); return true; case MENU MAIN:

intent.setClass(Setting.this, iTracks.class); startActi vity(intent); return true; case MENU BACK: //¡MIrI

return true; >

mimtmit 31», *>»jmwn - \ -wmm" # «mv km'IW -raw. ^ii^ra^i kW/JN':

(^Override protected void onStopO i super.onStop();

Log.d(TAG, "save setting infos");

0 0

Post a comment