コード例 #1
0
ファイル: AndroidCallUtil.java プロジェクト: gaixiaochuan/BIM
  /**
   * Shows "call via" menu allowing user to selected from multiple providers.
   *
   * @param context the android context
   * @param v the View that will contain the popup menu.
   * @param destination target callee name.
   */
  private static void showCallViaMenu(final Context context, View v, final String destination) {
    PopupMenu popup = new PopupMenu(context, v);

    Menu menu = popup.getMenu();

    Iterator<ProtocolProviderService> registeredProviders =
        AccountUtils.getRegisteredProviders().iterator();

    while (registeredProviders.hasNext()) {
      final ProtocolProviderService provider = registeredProviders.next();
      String accountAddress = provider.getAccountID().getAccountAddress();

      MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, accountAddress);

      menuItem.setOnMenuItemClickListener(
          new MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
              createCall(context, destination, provider);

              return false;
            }
          });
    }

    popup.show();
  }
コード例 #2
0
ファイル: v11.java プロジェクト: notbryant/eyebrows-sync
  // Overridden Methods
  void showItemMenu(View v, String name, ArrayList<SimpleMenuItem> menuItems) {
    PopupMenu popupMenu = new PopupMenu(v11.this, v);
    popupMenu.getMenu().clear();

    for (int i = 0; i < menuItems.size(); i++)
      popupMenu
          .getMenu()
          .add(
              0, menuItems.get(i).getItemId(),
              0, menuItems.get(i).getTitle());

    popupMenu.getMenu().findItem(R.id.status).setVisible(syncers.get(name) != null);

    popupMenu.setOnMenuItemClickListener(v11.this);
    popupMenu.show();
  }