1 /* 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 17 package android.view.menu; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.view.ContextMenu; 22 import android.view.ContextMenu.ContextMenuInfo; 23 import android.view.View; 24 25 import com.android.frameworks.coretests.R; 26 27 public 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 onCreate(Bundle savedInstanceState)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 onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)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 getTargetLtr()47 View getTargetLtr() { 48 return findViewById(R.id.context_menu_target_ltr); 49 } 50 getTargetRtl()51 View getTargetRtl() { 52 return findViewById(R.id.context_menu_target_rtl); 53 } 54 } 55