Example usage for android.view MenuItem getItemId

List of usage examples for android.view MenuItem getItemId

Introduction

In this page you can find the example usage for android.view MenuItem getItemId.

Prototype

public int getItemId();

Source Link

Document

Return the identifier for this menu item.

Usage

From source file:net.mEmoZz.PopMovies.frags.DetailFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_share) {
        createShareForecastIntent();//from   w w w.j a  va  2s  .c o  m
    }
    return super.onOptionsItemSelected(item);
}

From source file:ln.paign10.arduinopixel.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.settings:
        mDialog = new IpDialog();
        mDialog.show(getFragmentManager(), "Settings");
        break;//from   w  w  w . j av a 2 s . c  om
    case R.id.server_code:
        openURL();
        break;
    default:
        break;
    }
    return true;
}

From source file:nl.terr.tabweave.TabWeave.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menuSettings:
        showSettings();/* w w  w.j  a  v a 2 s  .  co m*/
        return true;

    case R.id.menuRefresh:
        refreshTabList();
        return true;
    }

    return super.onMenuItemSelected(featureId, item);
}

From source file:com.cloudkick.NodeViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.do_connectbot:
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String user = prefs.getString("sshUser", "root");
        Integer port = new Integer(prefs.getString("sshPort", "22"));
        String uri = "ssh://" + user + "@" + node.ipAddress + ":" + port + "/#" + user;
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        try {/*from   w  w  w .  jav  a2s . c o  m*/
            startActivity(i);
        } catch (ActivityNotFoundException e) {
            // Suggest ConnectBot
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("SSH Client Not Found");
            String mfaMessage = ("The ConnectBot SSH Client is required to complete this operation. "
                    + "Would you like to install ConnectBot from the Android Market now?");
            builder.setMessage(mfaMessage);
            builder.setCancelable(true);
            builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent marketActivity = new Intent(Intent.ACTION_VIEW);
                    marketActivity.setData(Uri.parse("market://details?id=org.connectbot"));
                    startActivity(marketActivity);
                }
            });
            builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
            AlertDialog mfaDialog = builder.create();
            mfaDialog.show();
        }
        return true;
    default:
        // If its not recognized, do nothing
        return super.onOptionsItemSelected(item);
    }
}

From source file:net.oschina.app.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
    case R.id.search:
        UIHelper.showSimpleBack(this, SimpleBackPage.SEARCH);
        break;/*from   w w  w .j  av  a 2s.  c om*/

    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.cloudant.todo.TodoActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.action_new:
        this.showDialog(DIALOG_NEW_TASK);
        return true;
    case R.id.action_download:
        this.showDialog(DIALOG_PROGRESS);
        sTasks.startPullReplication();//from  w  ww . j a v a2 s.  co  m
        return true;
    case R.id.action_upload:
        this.showDialog(DIALOG_PROGRESS);
        sTasks.startPushReplication();
        return true;
    case R.id.action_settings:
        this.startActivity(new Intent().setClass(this, SettingsActivity.class));
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.notifry.android.SourceList.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        Intent intent = new Intent(this, ChooseAccount.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);/* w  w w  . j  ava 2  s. c  o m*/
        return true;
    case ADD_SOURCE:
        askForSourceName();
        return true;
    case REFRESH_SERVER:
        syncWithServer();
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    //add pair to dashboard action
    case R.id.action_add:
        final CheckBoxListAdapter checkBoxListAdapter = new CheckBoxListAdapter(getActivity(),
                getResources().getStringArray(R.array.ExchangePairs), CheckBoxListAdapter.SettingsScope.PAIRS);
        ListView listView = new ListView(getActivity());
        listView.setAdapter(checkBoxListAdapter);
        new AlertDialog.Builder(getActivity()).setTitle(this.getString(R.string.SelectPairsPromptTitle))
                .setView(listView).setNeutralButton(getResources().getString(R.string.DialogSaveButton),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                checkBoxListAdapter.saveValuesToPreferences();
                                updateStorageWithTickers();
                                mTickersDashboardAdapter.update();
                                getActivity()
                                        .sendBroadcast(new Intent(getActivity(), StartServiceReceiver.class));
                            }//from  w  ww .  ja  v  a2s. com
                        })
                .show();
        break;
    //refresh dashboard action
    case R.id.action_refresh:
        mRefreshItem = item;
        mRefreshItem.setActionView(R.layout.progress_bar_action_view);
        mRefreshItem.expandActionView();
        getActivity().sendBroadcast(new Intent(getActivity(), StartServiceReceiver.class));
        break;
    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.dwdesign.tweetings.fragment.ConversationFragment.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SHARE: {
        isShare = true;/* w w w . j  a  v  a2s .co  m*/
        shareConversation(false);
        break;
    }
    case MENU_TWEET_CONVERSATION: {
        isShare = false;
        shareConversation(true);
        break;
    }
    }
    return super.onOptionsItemSelected(item);
}

From source file:org.quantumbadger.redreader.activities.InboxListingActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case OPTIONS_MENU_MARK_ALL_AS_READ:

        RedditAPI.markAllAsRead(CacheManager.getInstance(this),
                new APIResponseHandler.ActionResponseHandler(this) {
                    @Override/*from   w w w  .  j a v  a2  s  .c  o  m*/
                    protected void onSuccess() {
                        General.quickToast(context, R.string.mark_all_as_read_success);
                    }

                    @Override
                    protected void onCallbackException(final Throwable t) {
                        BugReportActivity.addGlobalError(
                                new RRError("Mark all as Read failed", "Callback exception", t));
                    }

                    @Override
                    protected void onFailure(final RequestFailureType type, final Throwable t,
                            final StatusLine status, final String readableMessage) {
                        final RRError error = General.getGeneralErrorForFailure(context, type, t, status,
                                "Reddit API action: Mark all as Read");
                        AndroidApi.UI_THREAD_HANDLER.post(new Runnable() {
                            public void run() {
                                General.showResultDialog(InboxListingActivity.this, error);
                            }
                        });
                    }

                    @Override
                    protected void onFailure(final APIFailureType type) {

                        final RRError error = General.getGeneralErrorForFailure(context, type);
                        AndroidApi.UI_THREAD_HANDLER.post(new Runnable() {
                            public void run() {
                                General.showResultDialog(InboxListingActivity.this, error);
                            }
                        });
                    }
                }, RedditAccountManager.getInstance(this).getDefaultAccount(), this);

        return true;
    case android.R.id.home:
        finish();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}