blob: 830b3d549773f55b861fbeddfa550f617bc5208e [file] [log] [blame]
Vladislav Kaznacheevd959c9d2018-01-23 14:03:36 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy 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,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.view.menu;
18
19import android.app.Activity;
20import android.os.Bundle;
21import android.view.ContextMenu;
22import android.view.ContextMenu.ContextMenuInfo;
23import android.view.View;
24
25import com.android.frameworks.coretests.R;
26
27public class ContextMenuActivity extends Activity {
28
29 static final String LABEL_ITEM = "Item";
30 static final String LABEL_SUBMENU = "Submenu";
31 static final String LABEL_SUBITEM = "Subitem";
32
33 @Override
34 protected void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState);
36 setContentView(R.layout.context_menu);
37 registerForContextMenu(getTargetLtr());
38 registerForContextMenu(getTargetRtl());
39 }
40
41 @Override
42 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
43 menu.add(LABEL_ITEM);
44 menu.addSubMenu(LABEL_SUBMENU).add(LABEL_SUBITEM);
45 }
46
47 View getTargetLtr() {
48 return findViewById(R.id.context_menu_target_ltr);
49 }
50
51 View getTargetRtl() {
52 return findViewById(R.id.context_menu_target_rtl);
53 }
54}