Listing 127 Show Settingsjava implements the code behind the settings screen

package com.msi.manning.UnlockingAndroid;

// multiple imports trimmed for brevity, see full source code public class ShowSettings extends Activity { Prefs myprefs = null; @Override public void onCreate (Bundle icicle) { Initialize Prefs Q

super. onCreate (icicle) ; instance setContentView(R.layout.showsettings);

myprefs = new Prefs (this . getApplicationContext () ) ; <J-PopulateScreen () ; <1-

Populate UI elements final Button savebutton = (Button) findViewByld(R.id.settingssave); savebutton.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) {

D Connect

EditText to UI

final EditText email=

(EditText)findViewById(R.id.emailaddress); if (email.getText().length() == 0) { // display dialog, see full source code return;

final EditText serverurl =

(EditText)findViewById(R.id.serverurl); if (serverurl.getText().length() == 0) { // display dialog, see full source code return;

myprefs . setEmail (email .getText (). toString ()) ; I Store and myprefs.setServer(serverurl.getText() . toString ()) ; 1/ save settings myprefs.save() ; I

0 0

Post a comment