(savedInstanceState); setContentView
username = (EditText) findViewById
submit=(Button)findViewById
userage = (EditText) findViewById show=(Button)findViewById }
@Override
public void onClick(View v) {
(this);
(this);
SharedPreferences share = (FILENAME,;
switch ()) { editor = ();
String name = ().toString().trim(); String age = ().toString().trim();
(\, name); (\, (age)); (); break;
case
case (\, \没有 姓名信息\));
}
(\, 0))); break;
default: }
break;
}
OptionMenu
package class MainActivity extends Activity { private ImageView imageView = null; @Override
protected void onCreate(Bundle savedInstanceState) { (savedInstanceState);
setContentView
imageView = (ImageView) findViewById
@Override
public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate menu); return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) { int itemId = ();
if (itemId == {
Resources resources = getBaseContext().getResources();
Drawable btnDrawable =
(btnDrawable);
}
return (item);
}
}
}
ListView
package class MainActivity extends Activity {
private ListView listView = null; @Override
protected void onCreate(Bundle savedInstanceState) { }
@Override
public boolean onCreateOptionsMenu(Menu menu) { }
private List
List
getMenuInflater().inflate menu); return true;
(savedInstanceState);
listView = new ListView(this); (new ArrayAdapter
(new ItemClickEvent());
setContentView(listView);
}
return data;
protected class ItemClickEvent implements OnItemClickListener{
@Override
long arg3) {
public void onItemClick(AdapterView<> arg0, View arg1, int arg2,
}
}
}
菜单的创建
package class MainActivity extends Activity {
ListView lv=null;
@Override
protected void onCreate(Bundle savedInstanceState) { (savedInstanceState); lv=new ListView(this); ArrayAdapter
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
ainActivity\ >