Iftmmwmtfw mtft hrwaftPi

Intent intent new Intent (); switch (item.qetItemld()) | case MENU NEW:

intent.setCIass(iTracks.thi s, NewTrack.class); startActivity(intent) ; return true;

mmW&'iffFiSilJf "SrififfiJS" (NewTrack) Mim Activity. mMmmmM, i5ifii -tmmfc, ^lUm-AL^nm r^rrit layout tm tfl" new track.xmlt It'i'^fW^ill h'W-K:

<?xml version-"1.0" enccding="utf-8"?>

<L i near Layout xmln s:and r oi d="h ttp://sch ema s.a rid r o i d . com / ap k / r es /andr o .i d" a ndr oid: o r i en t a t ion = " ve r t i ca 1" andr.o id: 1 a you t _wi d t. h "fill pa rent" android:layout height^"fill parent">

<TextView android:layout_width=Mfill parent" android:1ayout_height-"wrap content" android:text "@string/new tips" />

<TextView android:Iay6ut_width "fill_parent" android:layout height "wrap content" andro id: t c-xt = " 0s t ring /new name " /> <EditText android:id="@+id/new name" an d r o i d:1a yo u t _w i dth-"f i11pa rent" android: layout_height- "wrap content." android:text="" />

<TextV Lev; android: layou t widt:h= " f i 11 _ pa rent" android:layout height "wrap content" android:text "G-string/new desc" /> <EditText android:id-"@+ id/new_desc" android:layout width="fill parent"

android: layout height="wrap_content" android:layout_weight "I" a na r o i d: sc r o 11 ba r s - " v e r t i ca 1" / > <Button android:id="@+id/new submit" android: layout _widtn="wrap_content" android:layout height="wrap content" android: text="@string/new_submit" />

</LinearLayout> ^itfilfff:

/I! new track, xm I rK LinearLayout if ttS Text View iE

ill EditText Äßttfll Button fflfr*«Xffl/'ÄAttiSÄ.

Ij il NewTrack.java Xft, •^JSffliRBffllHJfKjigl:, private static final String TAG "NewTrack"; private Button button new; private EditText field new name; private EditText field new_desc;

Küi^fi'-it TAG Jl] % idÄ I 1 fl*Jid»button new JIJ^^««t W @+id/new_submit field new name ill field_new desc miiAAX- onCreate layout, Fffttfi

^Override public void onCreate(Bundle savedlnstanceState) ( super.onCreate(savedlnstanceState); setContentView(R.layout.new track); setTi tie(R.string.menu_new); findViews(); setListensers(); I

onCrealeOA'ü1!1, setContentView ^^^Ä^lSW^^^tRÄ newtrack (

it: new track.xml), «SjgiHffl actntlcOÄSÄÄHt ÖMffilMJ findViews()«iR«HR + WÖlft-. ¿Mi J I] setListensers( Ä + ftlftffl SB »Cr ».

t&ftH'W» find vie ws ti & ÄJflfciett««* 7® » ffl i'J M fö # ffij, Ä&afWftiTW^:

private void findViews() ( Log.d(TAG, "find Views");

field new_name (EditText) t i ndViewByld (R. id. new_name) ; field new desc (EdjtText) findViewByld(R.id.new desc); button sew - (Button) findViewByld(R.id.new submit) ;

l.&iWftmmiU findViewByld( -T-mtmt} EditText onCreate //¿¿'I'M setListcnsers ?j öiJB^Ä/iiW 3S. äÄ^JlSSSfe buttonnew föflMMJHt U|J nf, ^Ä^WÖI F0W:

I private void setListensers() ( Log . d (TAG, "set Lister.ser s" ) ;

button_new.setOnClickListener(new track); }

h&fWfi&Wij Button Wi setOnClickListener()8 51! 3t^-itrffi¥'1)*/.USRffSSnew tracko track.

private Button.OnClickListener new track = new Button.OnCiickListener() { public void onClick(View v) I Log.d(TAG, "onClick new track.."); try (

String name (field new name.getText().toString()); String desc = (fieid_new_desc.getText0 .toString()); if (name.equals("")) \ Toast.makeText(NewTrack.this, getString(R.string.new name_nul1), Toast.LENGTHSHORT).show(); ) else \

// TODO Service

) catch (Exception err) I Log.e(TAG, "error: " + err.toString());

Toast.makeText(NewTrack.this, getString(R.string.new fai1), Toast.LENGTH SHORT).show(); ) ) };

ijc {RfctiLX -1 Button.OnClickListencr( %, Wn&MR- onClick()/j ft MM 4«. /hit onciickoA'ft. finss^fiiiM. warn Toast m>j:< -mm.x-r-: »«WW»«, pwis&jgcJt tpmix TODO ttMJj, mmmmmfrT-wffi&fc

Prfetil C,PS inMii® Service. Ju liii /jn W'jc o ft^&ifl-M 13-5 ffiw.

3. SGSM^AiftMIMI!

case MENU SETTING:

intent.setClass(iTracks.this, Setting.class); startActlvity(intent); return true;

i WJWf-ft:

MENU SETTING"WlMMifttti j , Iff fi~F -^gffff M WM& Setting, it-itllJ startActivity Vi^J'tT.

Activity. m\

ftllGPSaiSPrfKlii«. Map ftittilSS«.

itifiiufii. &«iesft*f7*iu$, umikmm^mwmu.

'R&ffflJ Share Pre Terence •

j£ft»J!Bfflri0A<i ui M'J, fi'JiÜÄt Activity «»»«¡fliett-. MläffittÄfirfcÄ

setting.xml,

<?xml version-"1.0" encoding="utf-8"?>

<I,inearLayout- xmins : android^"ht tp: //schemas . android. com/apk/res/android" android:or ientat ion—"vejt ica1" android:layout _wi d'th= "fill parent" android:layout height-"L ill_parent">

CTextView android: id="0+id/set ting trip.-?."

android:layout wrdth="fi 1 1 parent" android:Iayout_height~"wrap_content" android:text="" />

CTextView android:layout_width="fill parent" android:layout height«"wrap content" android:text "@string/sntting_gps" />

<Spinner android: id™"@ + id/s«Bt-t.ing gps" android:1ayout_width="fill parent" android: layout height="wrap content." android:drawSelectorOnTop "true" android:prompt="@string/spinner gps prompt" />

<TextView android:layout width="fill_parent" android:layout height "wrap_content" android: text="@stri rig/setting map level" />

<Spinner android:id-• id/setting_map level" android:layout width-"fill_parent" android:layout height="wrap content" androi d:drawSele.ctor0nTop=" true" android:prompt "@string/spinner map prompt" />

<But.ton android: id="@ + id/setting submi t" android:layout width~"wrap_content" android:Iayout height="wrap content" android:text="@string/setting_submit" />

</LinearLayout>

setting.xml, ÄfiHiW-tbÄ LinearLayout ^fct, jHi'ffl Spinner mnm^ ^i&wpmmi i-w«*. «riitw t Button fim^/ij^awrmti..

ßHäF. Sctting.java , ^r'iijj -«HffSttmffllgft. H$ft» KJWii:

private static final String TAG = "Setting";

private static final int MENU_MAIN = Menu. FIRST + 1; private static final int MENU_NEW MENU MAIN + 1; private static final int MENU BACK = MENU_NEW ♦ 1;;

public static final String SETTING INFOS = "SETTING Infos";

</LinearLayout>

public st.at i c fina. String SETTING_GPS = "SETTING Gps";

public static final String SETTING MAP = "SETTING Map";

public static final String SETTING"GPS POSITON = "SETTING Gps p";

public static final String SETTING MAP POSITON - "SETTING Map p";

private Button but: ton_sett ±ng_submi t ;

private Spinner field sett- ing_gps;

private Spinner field_setting_map level;

%>Jvi{\. onCrcate 'Isetting.xml lUuhttPM,

@0ver;r ide public void onGreatCi (Bundle savedlnstanceState) ( super.onCreate(savedlnstanceState); setContentView(R.layout.setting); set.Ti t le (P.. string.menu setting) ; f indViews(); set.Lis tensers(); restorePrefs{>; )

H immw:

setContentView()&& it-*fff<J ft M Xft setting.xml, setTitle()«5EJt fcjg. ittifu'WII fmdViews( MmmiiXi nmwm n. )\m\ setListensers()*ft&ffl ¿oil VAi&ii g. jajfiiilffl restorePrefsO^S*:iAifieK#/H/JWflitL1.o findviewsoff]tp.yff®ftwwinw. -zmmtm private void f'indViewsO \ Log.d(TAG, "find Views");

button sot ting submit = (Button) findViewByld(R.id.set Ling submit); field setting gps (Spinner) f indViewByld(R.id.setting_gps);

ArrayAdapI.er<CharSeque n c e > adapter - ArrayAdapter. createFromResource ( this, R.array.gps, android.R.layout.simple spinner item);

adapter.setDropDownViewResource(android.R.1ayout.simpie_ spinner dropdown_item); fieid_setting gps.setAdapter(adapter);

field settingmap level - (Spinner) findVi.ewByld (R. id. setting map level);

ArrayAdap»:er<CharSequence> adapter 2 = Ar rayAdapter . crea teFromResource ( this, R. array.map, android. R. layout. simple spir.ner_item) ; adapter2.setDropDownViewResource(android.R.layout.simple spinner_dropdown item); field settingjmap level.setAdapter(adapter?);

0 0

Post a comment