Search in sources :

Example 1 with ContextMenuInfo

use of android.view.ContextMenu.ContextMenuInfo in project android_frameworks_base by AOSPA.

the class View method createContextMenu.

/**
     * Show the context menu for this view. It is not safe to hold on to the
     * menu after returning from this method.
     *
     * You should normally not overload this method. Overload
     * {@link #onCreateContextMenu(ContextMenu)} or define an
     * {@link OnCreateContextMenuListener} to add items to the context menu.
     *
     * @param menu The context menu to populate
     */
public void createContextMenu(ContextMenu menu) {
    ContextMenuInfo menuInfo = getContextMenuInfo();
    // Sets the current menu info so all items added to menu will have
    // my extra info set.
    ((MenuBuilder) menu).setCurrentMenuInfo(menuInfo);
    onCreateContextMenu(menu);
    ListenerInfo li = mListenerInfo;
    if (li != null && li.mOnCreateContextMenuListener != null) {
        li.mOnCreateContextMenuListener.onCreateContextMenu(menu, this, menuInfo);
    }
    // Clear the extra information so subsequent items that aren't mine don't
    // have my extra info.
    ((MenuBuilder) menu).setCurrentMenuInfo(null);
    if (mParent != null) {
        mParent.createContextMenu(menu);
    }
}
Also used : ContextMenuInfo(android.view.ContextMenu.ContextMenuInfo) MenuBuilder(com.android.internal.view.menu.MenuBuilder)

Example 2 with ContextMenuInfo

use of android.view.ContextMenu.ContextMenuInfo in project platform_frameworks_base by android.

the class View method createContextMenu.

/**
     * Show the context menu for this view. It is not safe to hold on to the
     * menu after returning from this method.
     *
     * You should normally not overload this method. Overload
     * {@link #onCreateContextMenu(ContextMenu)} or define an
     * {@link OnCreateContextMenuListener} to add items to the context menu.
     *
     * @param menu The context menu to populate
     */
public void createContextMenu(ContextMenu menu) {
    ContextMenuInfo menuInfo = getContextMenuInfo();
    // Sets the current menu info so all items added to menu will have
    // my extra info set.
    ((MenuBuilder) menu).setCurrentMenuInfo(menuInfo);
    onCreateContextMenu(menu);
    ListenerInfo li = mListenerInfo;
    if (li != null && li.mOnCreateContextMenuListener != null) {
        li.mOnCreateContextMenuListener.onCreateContextMenu(menu, this, menuInfo);
    }
    // Clear the extra information so subsequent items that aren't mine don't
    // have my extra info.
    ((MenuBuilder) menu).setCurrentMenuInfo(null);
    if (mParent != null) {
        mParent.createContextMenu(menu);
    }
}
Also used : ContextMenuInfo(android.view.ContextMenu.ContextMenuInfo) MenuBuilder(com.android.internal.view.menu.MenuBuilder)

Example 3 with ContextMenuInfo

use of android.view.ContextMenu.ContextMenuInfo in project android_frameworks_base by ParanoidAndroid.

the class View method createContextMenu.

/**
     * Show the context menu for this view. It is not safe to hold on to the
     * menu after returning from this method.
     *
     * You should normally not overload this method. Overload
     * {@link #onCreateContextMenu(ContextMenu)} or define an
     * {@link OnCreateContextMenuListener} to add items to the context menu.
     *
     * @param menu The context menu to populate
     */
public void createContextMenu(ContextMenu menu) {
    ContextMenuInfo menuInfo = getContextMenuInfo();
    // Sets the current menu info so all items added to menu will have
    // my extra info set.
    ((MenuBuilder) menu).setCurrentMenuInfo(menuInfo);
    onCreateContextMenu(menu);
    ListenerInfo li = mListenerInfo;
    if (li != null && li.mOnCreateContextMenuListener != null) {
        li.mOnCreateContextMenuListener.onCreateContextMenu(menu, this, menuInfo);
    }
    // Clear the extra information so subsequent items that aren't mine don't
    // have my extra info.
    ((MenuBuilder) menu).setCurrentMenuInfo(null);
    if (mParent != null) {
        mParent.createContextMenu(menu);
    }
}
Also used : ContextMenuInfo(android.view.ContextMenu.ContextMenuInfo) MenuBuilder(com.android.internal.view.menu.MenuBuilder)

Example 4 with ContextMenuInfo

use of android.view.ContextMenu.ContextMenuInfo in project XobotOS by xamarin.

the class View method createContextMenu.

/**
     * Show the context menu for this view. It is not safe to hold on to the
     * menu after returning from this method.
     *
     * You should normally not overload this method. Overload
     * {@link #onCreateContextMenu(ContextMenu)} or define an
     * {@link OnCreateContextMenuListener} to add items to the context menu.
     *
     * @param menu The context menu to populate
     */
public void createContextMenu(ContextMenu menu) {
    ContextMenuInfo menuInfo = getContextMenuInfo();
    // Sets the current menu info so all items added to menu will have
    // my extra info set.
    ((MenuBuilder) menu).setCurrentMenuInfo(menuInfo);
    onCreateContextMenu(menu);
    if (mOnCreateContextMenuListener != null) {
        mOnCreateContextMenuListener.onCreateContextMenu(menu, this, menuInfo);
    }
    // Clear the extra information so subsequent items that aren't mine don't
    // have my extra info.
    ((MenuBuilder) menu).setCurrentMenuInfo(null);
    if (mParent != null) {
        mParent.createContextMenu(menu);
    }
}
Also used : ContextMenuInfo(android.view.ContextMenu.ContextMenuInfo) MenuBuilder(com.android.internal.view.menu.MenuBuilder)

Example 5 with ContextMenuInfo

use of android.view.ContextMenu.ContextMenuInfo in project AndroidTraining by mixi-inc.

the class MainActivity method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() != R.id.DeleteListItem && item.getItemId() != R.id.AddListItem) {
        return false;
    }
    // MenuItemからContextMenuInfoを取得し、AdapterContextMenuInfoにキャストします
    ContextMenuInfo menuInfo = item.getMenuInfo();
    AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo) menuInfo;
    // AdapterContextMenuInfoから長押ししたリストアイテムのpositionを取得します
    int position = adapterInfo.position;
    // ListViewから長押しされたリストアイテムを取得します
    Book book = (Book) mListView.getItemAtPosition(position);
    if (item.getItemId() == R.id.DeleteListItem) {
    // TODO:Adapterを使用して長押ししたデータを削除してください
    } else if (item.getItemId() == R.id.AddListItem) {
    // TODO:Adapterを使用して長押ししたデータを追加してください
    }
    return true;
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) ContextMenuInfo(android.view.ContextMenu.ContextMenuInfo)

Aggregations

ContextMenuInfo (android.view.ContextMenu.ContextMenuInfo)9 MenuBuilder (com.android.internal.view.menu.MenuBuilder)6 Paint (android.graphics.Paint)1 InputFilter (android.text.InputFilter)1 ActionMode (android.view.ActionMode)1 ContextMenu (android.view.ContextMenu)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AdapterContextMenuInfo (android.widget.AdapterView.AdapterContextMenuInfo)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 FrameLayout (android.widget.FrameLayout)1 Component (com.codename1.ui.Component)1 TextArea (com.codename1.ui.TextArea)1 Method (java.lang.reflect.Method)1