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

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

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

ContextMenu.setHeaderTitle介绍

暂无

代码示例

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

@Override
public void onCreateContextMenu(ContextMenu contextMenu,
                View v,
                ContextMenu.ContextMenuInfo menuInfo) {
  AdapterView.AdapterContextMenuInfo info =
      (AdapterView.AdapterContextMenuInfo) menuInfo;
  selectedWord = ((TextView) info.targetView).getText().toString();
  selectedWordId = info.id;

  contextMenu.setHeaderTitle(selectedWord);
  contextMenu.add(0, CONTEXT_MENU_EDIT_ITEM, 0, R.string.edit);
  contextMenu.add(0, CONTEXT_MENU_DELETE_ITEM, 1, R.string.delete);
}

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

@Override
 public void onCreateContextMenu(ContextMenu menu, View v,
     ContextMenuInfo menuInfo) {
   menu.setHeaderTitle("Select The Action");    
   menu.add(0, v.getId(), 0, "Call");//groupId, itemId, order, title   
   menu.add(0, v.getId(), 0, "SMS"); 
 }

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

menu.setHeaderTitle(page);
menu.add(0, MENU_READ, 0, “Read page”);
menu.add(0, MENU_EDIT, 0, “Edit page”);
menu.add(0, MENU_FAVORITE, 0, “Add page to favorites”);
menu.add(0, MENU_EXPORT, 0, “Export page to file”);
menu.add(0, MENU_DELETE, 1, “Delete page”);

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

@Override
protected void onCreateContextMenu(ContextMenu menu) {
  super.onCreateContextMenu(menu);

  HitTestResult result = getHitTestResult();

  MenuItem.OnMenuItemClickListener handler = new MenuItem.OnMenuItemClickListener() {
    public boolean onMenuItemClick(MenuItem item) {
        // do the menu action
        return true;
    }
  };

  if (result.getType() == HitTestResult.IMAGE_TYPE ||
      result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
    // Menu options for an image.
    //set the header title to the image url
    menu.setHeaderTitle(result.getExtra());
    menu.add(0, ID_SAVEIMAGE, 0, "Save Image").setOnMenuItemClickListener(handler);
    menu.add(0, ID_VIEWIMAGE, 0, "View Image").setOnMenuItemClickListener(handler);
  } else if (result.getType() == HitTestResult.ANCHOR_TYPE ||
      result.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
    // Menu options for a hyperlink.
    //set the header title to the link url
    menu.setHeaderTitle(result.getExtra());
    menu.add(0, ID_SAVELINK, 0, "Save Link").setOnMenuItemClickListener(handler);
    menu.add(0, ID_SHARELINK, 0, "Share Link").setOnMenuItemClickListener(handler);
  }
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
  super.onCreateContextMenu(menu, v, menuInfo);
  AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
  String title = ((MyItem) mAdapter.getItem(info.position)).getTitle();
  menu.setHeaderTitle(title);

  menu.add(Menu.NONE, MENU_CONTEXT_DELETE_ID, Menu.NONE, DELETE_TEXT);
}

@Override
public boolean onContextItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  case MENU_CONTEXT_DELETE_ID:
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Log.d(TAG, "removing item pos=" + info.position);
    mAdapter.remove(info.position);
    return true;
  default:
    return super.onContextItemSelected(item);
  }
}

代码示例来源:origin: k9mail/k-9

menu.setHeaderTitle(url);
menu.add(Menu.NONE, MENU_ITEM_LINK_VIEW, 0,
    context.getString(R.string.webview_contextmenu_link_view_action))
    .setOnMenuItemClickListener(listener);
menu.add(Menu.NONE, MENU_ITEM_LINK_SHARE, 1,
    context.getString(R.string.webview_contextmenu_link_share_action))
    .setOnMenuItemClickListener(listener);
menu.add(Menu.NONE, MENU_ITEM_LINK_COPY, 2,
    context.getString(R.string.webview_contextmenu_link_copy_action))
    .setOnMenuItemClickListener(listener);
menu.setHeaderTitle(inlineImage ?
    context.getString(R.string.webview_contextmenu_image_title) : uri.toString());
menu.setHeaderTitle(phoneNumber);
menu.add(Menu.NONE, MENU_ITEM_PHONE_CALL, 0,
menu.setHeaderTitle(email);
menu.add(Menu.NONE, MENU_ITEM_EMAIL_SEND, 0,

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
      // Create your context menu here
  menu.setHeaderTitle("Context Menu");
  menu.add(0, v.getId(), 0, "Action 1");        
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
  // TODO Auto-generated method stub
  super.onCreateContextMenu(menu, v, menuInfo);
  menu.setHeaderTitle("Send As..");
  menu.add(Menu.NONE, SEND_AS_TEXT, SEND_AS_TEXT, "Send As Text");
  menu.add(Menu.NONE, SEND_AS_IMAGE, SEND_AS_IMAGE, "Send As Image");
  btnId = v.getId(); //this is where I get the id of my clicked button
}

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

v, ContextMenu.ContextMenuInfo menuInfo){
  menu.setHeaderTitle("My Context Menu");
  menu.add(Menu.NONE, CONTEXT_MENU_VIEW, Menu.NONE, "Add");
  menu.add(Menu.NONE, CONTEXT_MENU_EDIT, Menu.NONE, "Edit");
  menu.add(Menu.NONE, CONTEXT_MENU_ARCHIVE, Menu.NONE, "Delete");

代码示例来源:origin: ukanth/afwall

private void initializeRecyclerView(final Context ctx) {
  recyclerView.hasFixedSize();
  recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
  recyclerViewAdapter = new LogDetailRecyclerViewAdapter(getApplicationContext(), logData -> {
    current_selected_logData = logData;
    recyclerView.showContextMenu();
  });
  recyclerView.setOnCreateContextMenuListener((menu, v, menuInfo) -> {
    menu.setHeaderTitle(R.string.select_the_action);
    //groupId, itemId, order, title
    //menu.add(0, v.getId(), 0, R.string.add_ip_rule);
    menu.add(0, v.getId(), 1, R.string.show_destination_address);
    menu.add(0, v.getId(), 2, R.string.show_source_address);
    menu.add(0, v.getId(), 3, R.string.ping_destination);
    menu.add(0, v.getId(), 4, R.string.ping_source);
    menu.add(0, v.getId(), 5, R.string.resolve_destination);
    menu.add(0, v.getId(), 6, R.string.resolve_source);
  });
  recyclerView.setAdapter(recyclerViewAdapter);
}

代码示例来源:origin: ukanth/afwall

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                ContextMenu.ContextMenuInfo menuInfo) {
  super.onCreateContextMenu(menu, v, menuInfo);
  AdapterView.AdapterContextMenuInfo aInfo = (AdapterView.AdapterContextMenuInfo) menuInfo;
  //ProfileData profile = profileAdapter.getItem(aInfo.position);
  String name = ((TextView) aInfo.targetView.findViewById(R.id.pro_name)).getText().toString();
  menu.setHeaderTitle(getString(R.string.select) + " " + name);
  if (G.isProfileMigrated()) {
    menu.add(0, MENU_RENAME, 0, getString(R.string.rename));
    // menu.add(0, MENU_CLONE, 0, getString(R.string.clone));
  }
  menu.add(0, MENU_DELETE, 0, getString(R.string.delete));
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
menu.setHeaderTitle("Sample Context Menu");
menu.add(200, 200, 200, "item1");
}

代码示例来源:origin: THEONE10211024/ApiDemos

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
  menu.setHeaderTitle("Sample menu");
  menu.add(0, 0, 0, R.string.expandable_list_sample_action);
}

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

@Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) 
{    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo; 
    menu.setHeaderTitle(songsarray[info.position]);
    // String[] menuItems = getResources().getStringArray(R.array.menu); 
    for (int i = 0; i<menuItems.length; i++)
       menu.add(Menu.NONE, i, i, menuItems[i]);
}

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

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

  AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
  MyObject obj = (MyObject) myListView.getItemAtPosition(info.position);

  menu.setHeaderTitle("Selection Options");  
  menu.add(0, v.getId(), 0, "Remove " + obj.name); 
}

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

@Override
public void onCreateContextMenu(ContextMenu contextMenu,
                View v,
                ContextMenu.ContextMenuInfo menuInfo) {
  AdapterView.AdapterContextMenuInfo info =
      (AdapterView.AdapterContextMenuInfo) menuInfo;
  selectedWord = ((TextView) info.targetView).getText().toString();
  selectedWordId = info.id;

  contextMenu.setHeaderTitle(selectedWord);
  contextMenu.add(0, CONTEXT_MENU_EDIT_ITEM, 0, R.string.edit);
  contextMenu.add(0, CONTEXT_MENU_DELETE_ITEM, 1, R.string.delete);
}

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

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

  if (v.getId() == R.id.listView1) {  //YOUR VIEW THAT IS ATTACHED TO LISTASK

    AdapterView.AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

    menu.setHeaderTitle("Options");
    String[] menuItems = { "Option1", "Option2", "Option3", "Option4"} };
    for (int i = 0; i < menuItems.length; i++) {
      menu.add(Menu.NONE, i, i, menuItems[i]);
    }

  }
}

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

textview.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
   @Override
   public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
       menu.setHeaderTitle("Context Menu");
       menu.add(R.id.whateverviewclicked, RENAME_MENU_ITEM, 0, "Rename");
       menu.add(R.id.whateverviewclicked, DELETE_MENU_ITEM, 1, "Delete");
      }
    });

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

int currentposition;

listview.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

  @Override
  public void onCreateContextMenu(ContextMenu menu, View v,
      ContextMenuInfo menuInfo) {
    // TODO Auto-generated method stub
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    currentposition = info.position;
    menu.setHeaderTitle("SELECT OPTION");
    menu.add(0, v.getId(), 0, "Delete ");

  }

});

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo){
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle("Profile Options");
    menu.add(0, 1000, 0, "Header1"); // give your menus distinct ids!!!
    menu.add(0, 1001, 0, "Header2");
}

相关文章