1 /** 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy 6 * of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 17 package android.view.menu; 18 19 import android.os.Bundle; 20 import android.view.Menu; 21 import android.widget.Button; 22 23 public class MenuLayout extends MenuScenario { 24 private static final String LONG_TITLE = "Really really really really really really really really really really long title"; 25 private static final String SHORT_TITLE = "Item"; 26 27 private Button mButton; 28 29 @Override onInitParams(Params params)30 protected void onInitParams(Params params) { 31 super.onInitParams(params); 32 params 33 .setNumItems(2) 34 .setItemTitle(0, LONG_TITLE) 35 .setItemTitle(1, LONG_TITLE); 36 } 37 38 @Override onPrepareOptionsMenu(Menu menu)39 public boolean onPrepareOptionsMenu(Menu menu) { 40 41 /* 42 * This activity is meant to try a bunch of different menu layouts. So, 43 * we recreate the menu every time it is prepared. 44 */ 45 menu.clear(); 46 onCreateOptionsMenu(menu); 47 48 return true; 49 } 50 getButton()51 public Button getButton() { 52 return mButton; 53 } 54 55 @Override onCreate(Bundle icicle)56 protected void onCreate(Bundle icicle) { 57 super.onCreate(icicle); 58 59 mButton = new Button(this); 60 setContentView(mButton); 61 } 62 63 } 64