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
17package android.view.menu;
18
19import android.view.menu.MenuScenario.Params;
20
21import android.os.Bundle;
22import android.view.Menu;
23import android.widget.Button;
24
25public class MenuLayout extends MenuScenario {
26    private static final String LONG_TITLE = "Really really really really really really really really really really long title";
27    private static final String SHORT_TITLE = "Item";
28
29    private Button mButton;
30
31    @Override
32    protected void onInitParams(Params params) {
33        super.onInitParams(params);
34        params
35            .setNumItems(2)
36            .setItemTitle(0, LONG_TITLE)
37            .setItemTitle(1, LONG_TITLE);
38    }
39
40    @Override
41    public boolean onPrepareOptionsMenu(Menu menu) {
42
43        /*
44         * This activity is meant to try a bunch of different menu layouts. So,
45         * we recreate the menu every time it is prepared.
46         */
47        menu.clear();
48        onCreateOptionsMenu(menu);
49
50        return true;
51    }
52
53    public Button getButton() {
54        return mButton;
55    }
56
57    @Override
58    protected void onCreate(Bundle icicle) {
59        super.onCreate(icicle);
60
61        mButton  = new Button(this);
62        setContentView(mButton);
63    }
64
65}
66