Life and Times
new MenuInflater(this).inflate(R.menu.option, menu);
return(super.onCreateOptionsMenu(menu));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.toast) {
String message="No restaurant selected";
if (current!=null) {
message=current.getNotes();
}
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
return(true);
}
else if (item.getItemId()==R.id.run) {
startWork();
return(true);
}
return(super.onOptionsItemSelected(item));
}
private void startWork() {
setProgressBarVisibility(true);
new Thread(longTask).start();
}
private void doSomeLongWork(final int incr) {
runOnUiThread(new Runnable() {
public void run() {
progress+=incr;
setProgress(progress);
}
});
SystemClock.sleep(^250 ); // should be something more useful!
}
private View.OnClickListener onSave=new View.OnClickListener() {
public void onClick(View v) {
current=new Restaurant();
current.setName(name.getText().toString());
current.setAddress(address.getText().toString());
current.setNotes(notes.getText().toString());
switch (types.getCheckedRadioButtonId()) {
case R.id.sit_down:
current.setType("sit_down");