MenuView.java revision 20ac724a3a836bfd362c911f7dc55a61c02b4d44
1/* 2 * Copyright (C) 2006 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.support.appcompat.view.menu; 18 19import android.support.appcompat.view.menu.MenuBuilder; 20import android.support.appcompat.view.menu.MenuItemImpl; 21 22import android.graphics.drawable.Drawable; 23 24/** 25 * Minimal interface for a menu view. {@link #initialize(MenuBuilder)} must be called for the menu 26 * to be functional. 27 * 28 * @hide 29 */ 30public interface MenuView { 31 32 /** 33 * Initializes the menu to the given menu. This should be called after the view is inflated. 34 * 35 * @param menu The menu that this MenuView should display. 36 */ 37 public void initialize(MenuBuilder menu); 38 39 /** 40 * Returns the default animations to be used for this menu when entering/exiting. 41 * 42 * @return A resource ID for the default animations to be used for this menu. 43 */ 44 public int getWindowAnimations(); 45 46 /** 47 * Minimal interface for a menu item view. {@link #initialize(MenuItemImpl, int)} must be 48 * called for the item to be functional. 49 */ 50 public interface ItemView { 51 52 /** 53 * Initializes with the provided MenuItemData. This should be called after the view is 54 * inflated. 55 * 56 * @param itemData The item that this ItemView should display. 57 * @param menuType The type of this menu, one of {@link MenuBuilder#TYPE_ICON}, {@link 58 * MenuBuilder#TYPE_EXPANDED}, {@link MenuBuilder#TYPE_DIALOG}). 59 */ 60 public void initialize(MenuItemImpl itemData, int menuType); 61 62 /** 63 * Gets the item data that this view is displaying. 64 * 65 * @return the item data, or null if there is not one 66 */ 67 public MenuItemImpl getItemData(); 68 69 /** 70 * Sets the title of the item view. 71 * 72 * @param title The title to set. 73 */ 74 public void setTitle(CharSequence title); 75 76 /** 77 * Sets the enabled state of the item view. 78 * 79 * @param enabled Whether the item view should be enabled. 80 */ 81 public void setEnabled(boolean enabled); 82 83 /** 84 * Displays the checkbox for the item view. This does not ensure the item view will be 85 * checked, for that use {@link #setChecked}. 86 * 87 * @param checkable Whether to display the checkbox or to hide it 88 */ 89 public void setCheckable(boolean checkable); 90 91 /** 92 * Checks the checkbox for the item view. If the checkbox is hidden, it will NOT be made 93 * visible, call {@link #setCheckable(boolean)} for that. 94 * 95 * @param checked Whether the checkbox should be checked 96 */ 97 public void setChecked(boolean checked); 98 99 /** 100 * Sets the shortcut for the item. 101 * 102 * @param showShortcut Whether a shortcut should be shown(if false, the value of shortcutKey 103 * should be ignored). 104 * @param shortcutKey The shortcut key that should be shown on the ItemView. 105 */ 106 public void setShortcut(boolean showShortcut, char shortcutKey); 107 108 /** 109 * Set the icon of this item view. 110 * 111 * @param icon The icon of this item. null to hide the icon. 112 */ 113 public void setIcon(Drawable icon); 114 115 /** 116 * Whether this item view prefers displaying the condensed title rather than the normal 117 * title. If a condensed title is not available, the normal title will be used. 118 * 119 * @return Whether this item view prefers displaying the condensed title. 120 */ 121 public boolean prefersCondensedTitle(); 122 123 /** 124 * Whether this item view shows an icon. 125 * 126 * @return Whether this item view shows an icon. 127 */ 128 public boolean showsIcon(); 129 } 130} 131