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);
}
}
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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations