Sunday, February 20, 2011

Android Development Study Notes 2 - Opiton Menus

strings.xml

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="AllDepartment">List All Depts</string>

<string name="Seach">Search</string>

</resources>

Add the following codes in the activity class


@Override

public boolean onCreateOptionsMenu(Menu menu) {

          menu.add(0, 0, 0,this.getResources().getString(R.string.AllDepartment));

          menu.add(0, 1, 1, this.getResources().getString(R.string.Seach));

return super.onCreateOptionsMenu(menu);

    }

When user click on "menu" button, 2 option menus would appear at the bottom of the screen.

No comments: