Android Programming Tutorials

(Romina) #1
Media

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.prefs) {
startActivity(new Intent(this, EditPreferences.class));

return(true);
}
else if (item.getItemId()==R.id.location) {
insertLocation();

return(true);
}
else if (item.getItemId()==R.id.help) {
startActivity(new Intent(this, HelpCast.class));

return(true);
}

return(super.onOptionsItemSelected(item));
}

With all that complete, we have our helpcast ready to go. Rebuild and


reinstall the application, and you will see the new help menu item:


Figure 41. The new option menu item in Patchy

248
Free download pdf