android.view.ContextMenu.setHeaderIcon()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中android.view.ContextMenu.setHeaderIcon()方法的一些代码示例,展示了ContextMenu.setHeaderIcon()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ContextMenu.setHeaderIcon()方法的具体详情如下:
包路径:android.view.ContextMenu
类名称:ContextMenu
方法名:setHeaderIcon

ContextMenu.setHeaderIcon介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
 super.onCreateContextMenu(menu, v, menuInfo);
 menu.setHeaderIcon(R.drawable.icon);
 menu.setHeaderTitle("Share Menu.");
 MenuInflater inflater = getMenuInflater();
 inflater.inflate(R.menu.contextmenu, menu);
}

代码示例来源:origin: stackoverflow.com

@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo){ 
super.onCreateContextMenu(context, v,menuInfo);
MenuInflater inflater = getMenuInflater();
menu.setHeaderTitle("YOUR TITLE");
menu.setHeaderIcon(R.drawable.YOUR DRAWABLE);
inflater.inflate(R.menu.YOUR_MENU_RESOURCE, menu);
}

代码示例来源:origin: stackoverflow.com

public void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  setContentView(R.layout.activity_main);

  listView = (ListView) findViewById(R.id.my_list);
  adapter = new MyAdapter(this,getModel());
  listView.setAdapter(adapter);
  listView.setOnItemLongClickListener(new PlayListOnItemLongClickListener());
}

private class PlayListOnItemLongClickListener implements AdapterView.OnItemLongClickListener {
  public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    registerForContextMenu(arg0);

    return false;
  }
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
  getMenuInflater().inflate(R.menu.context_playlist_operation, menu);
  menu.setHeaderIcon(R.drawable.ic_launcher);
  menu.setHeaderTitle("What do you want to do");
}

代码示例来源:origin: stackoverflow.com

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
  super.onCreateContextMenu(menu, v, menuInfo);

  AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

  menu.setHeaderTitle("title");
  menu.setHeaderIcon(R.drawable.alarm1_icon);
  menu.add(0, 0, 0, "test");
}

代码示例来源:origin: PrivacyApps/document-viewer

/**
 * {@inheritDoc}
 * 
 * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu, android.view.View,
 *      android.view.ContextMenu.ContextMenuInfo)
 */
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
  menu.clear();
  menu.setHeaderTitle(R.string.app_name);
  menu.setHeaderIcon(R.drawable.application_icon);
  final MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.mainmenu_context, menu);
  updateMenuItems(menu);
}

代码示例来源:origin: stackoverflow.com

menu.setHeaderIcon(something.getIcon());
menu.add(0, CONTEXT_MENU_SHARE, 0, "Do something!");

代码示例来源:origin: jp1017/ActivityLauncher

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
  AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
  MyActivityInfo activity = RecentTaskListFragment.this.activities[info.position];
  menu.setHeaderIcon(activity.icon);
  menu.setHeaderTitle(activity.name);
  menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut);
  menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch);
  super.onCreateContextMenu(menu, v, menuInfo);
}

代码示例来源:origin: stackoverflow.com

@Override
 public void onCreateContextMenu(ContextMenu menu, View v,
 ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Settings");
menu.setHeaderIcon(R.drawable.ic_settings);
menu.add(0, v.getId(), 0, "Action 1");
menu.add(0, v.getId(), 0, "Action 2");
menu.add(0, v.getId(), 0, "Action 3");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if (item.getTitle() == "Action 1") {
 Toast.makeText(this, "Action 1 invoked", Toast.LENGTH_SHORT).show();
} else if (item.getTitle() == "Action 2") {
 Toast.makeText(this, "Action 2 invoked", Toast.LENGTH_SHORT).show();
} else if (item.getTitle() == "Action 3") {
 Toast.makeText(this, "Action 3 invoked", Toast.LENGTH_SHORT).show();
} else {
 return false;
}
return true;
}

代码示例来源:origin: jp1017/ActivityLauncher

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
  menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut);
  menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch);
  
  ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo)menuInfo;
  ExpandableListView list = (ExpandableListView) getView().findViewById(R.id.expandableListView1);
  
  switch(ExpandableListView.getPackedPositionType(info.packedPosition)) {
  case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
    MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
    menu.setHeaderIcon(activity.icon);
    menu.setHeaderTitle(activity.name);
    menu.add(Menu.NONE, 2, Menu.NONE, R.string.context_action_edit);
    break;
  case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
    MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
    menu.setHeaderIcon(pack.icon);
    menu.setHeaderTitle(pack.name);
    break;
  }
  super.onCreateContextMenu(menu, v, menuInfo);
}

相关文章