Start Activity

Use AlertDialog H

private boolean validate() { boolean valid = true;

StringBuilder validationText = new StringBuilder(); if ((this.location.getText() == null) | |

this.location.getText().toString().equals("")) validationText.append(getResources().getString(

R.string.location_not_supplied_message)); valid = false;

newAlertDialog.Builder(this). I

setTitle (getResources () . getString (R. string. alert_label) ) . <1-'

setMessage(validationText.toString()). SetPositiveButton("Continue", new android.content.Dialoglnterface. 0nClickListener() { <-1 Respond to public void onClick( I button click

Dialoglnterface dialog, int argl) {

// do nothing, show alert is enough

return valid;

The menu items at the bottom of the Activity screens in figure 3.2 are all created using the onCreate0ptionsMenu() method O. Here we are using the Menu class add() method to create a single Menultem element O. We are passing a group ID, an ID, an order, and a text resource reference to create the menu item. We are also assigning to the menu item an icon with the setIcon method. The text and the image are externalized from the code, again using Android's concept of resources. The Menultem we have added duplicates the on-screen Button with the same label for the "Get reviews" purpose.

0 0

Post a comment