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:com.johan.voting.VotingActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    switch (id) {
    case R.id.action_info:
        Intent intent = new Intent(this, InfoActivity.class);
        startActivity(intent);/*from   www. j  a v a  2  s . c  om*/
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.scigames.slidegame.Registration3MassActivity.java

/**
 * Called when a menu item is selected./*  w  w w. j  a  v a  2 s .  c  o  m*/
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case BACK_ID:
        finish();
        return true;
    case CLEAR_ID:
        thisMass.setText("");
        //firstName.setText("");
        //password.setText("");
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:net.palacesoft.cngstation.client.StationActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.refresh:
        try {//from  ww w .  j a va 2s .  co  m
            Address locationAddress = lookupAddressFromLocation(currentLocation);
            new StationLoader(this, locationAddress, getZoomLevel(), STATIONS_URL).execute();
        } catch (AddressEmptyException e) {
            showInfoMessage("Could not determine your current location");
        } catch (IOException e) {
            showInfoMessage("Network error. Try refreshing.");
        }

        break;

    case R.id.search:
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.searchLayout);
        if (linearLayout.getVisibility() == View.VISIBLE) {
            linearLayout.setVisibility(View.INVISIBLE);
        } else {
            linearLayout.setVisibility(View.VISIBLE);
            if (countries == null) {
                initSearchForm();
                loadAvailableCountriesList();
            }
        }
        break;

    case R.id.settings:
        startActivity(new Intent(this, Preferences.class));
        break;

    case R.id.cheapest:
        try {
            stationOverlay.popupCheapest();
        } catch (Exception e) {
            logError(e, "Could not show the cheapest station");
        }
        break;

    case R.id.closest:
        try {
            stationOverlay.popupClosest();
        } catch (Exception e) {
            logError(e, "Could not show the closest station");
        }
        break;
    }

    return false;
}

From source file:com.lovejoy777sarootool.rootool.fragments.BrowserFragment.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.createfile:
        final DialogFragment dialog1 = new CreateFileDialog();
        dialog1.show(fm, BrowserActivity.TAG_DIALOG);
        return true;
    case R.id.createfolder:
        final DialogFragment dialog2 = new CreateFolderDialog();
        dialog2.show(fm, BrowserActivity.TAG_DIALOG);
        return true;
    default:/*from  w w w  .  j av  a2  s . c  o  m*/
        return false;
    }
}

From source file:microsoft.aspnet.signalr.client.test.integration.android.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_settings:
        startActivity(new Intent(this, SignalRPreferenceActivity.class));
        return true;

    case R.id.menu_run_tests:
        if (ApplicationContext.getServerUrl().trim().equals("")) {
            startActivity(new Intent(this, SignalRPreferenceActivity.class));
        } else {/*  ww  w . ja  va 2  s . co  m*/
            runTests();
        }
        return true;

    case R.id.menu_check_all:
        changeCheckAllTests(true);
        return true;

    case R.id.menu_uncheck_all:
        changeCheckAllTests(false);
        return true;

    case R.id.menu_reset:
        refreshTestGroupsAndLog();
        return true;

    case R.id.menu_view_log:
        AlertDialog.Builder logDialogBuilder = new AlertDialog.Builder(this);
        logDialogBuilder.setTitle("Log");

        final WebView webView = new WebView(this);

        String logContent = TextUtils.htmlEncode(mLog.toString()).replace("\n", "<br />");
        String logHtml = "<html><body><pre>" + logContent + "</pre></body></html>";
        webView.loadData(logHtml, "text/html", "utf-8");

        logDialogBuilder.setPositiveButton("Copy", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                clipboardManager.setText(mLog.toString());
            }
        });

        final String postContent = mLog.toString();

        logDialogBuilder.setNeutralButton("Post data", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                new AsyncTask<Void, Void, Void>() {

                    @Override
                    protected Void doInBackground(Void... params) {
                        try {
                            String url = ApplicationContext.getLogPostURL();
                            if (url != null && url.trim() != "") {
                                url = url + "?platform=android";
                                HttpPost post = new HttpPost();
                                post.setEntity(new StringEntity(postContent, "utf-8"));

                                post.setURI(new URI(url));

                                new DefaultHttpClient().execute(post);
                            }
                        } catch (Exception e) {
                            // Wasn't able to post the data. Do nothing
                        }

                        return null;
                    }
                }.execute();
            }
        });

        logDialogBuilder.setView(webView);

        logDialogBuilder.create().show();
        return true;

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

From source file:net.nym.mutils.ui.test.TestWebViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    switch (id) {
    case android.R.id.home:
        onBackPressed();/*www  .j  a  v  a2s. com*/
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.lovejoy777sarootool.rootool.fragments.BrowserFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.folderinfo:
        final DialogFragment dirInfo = new DirectoryInfoDialog();
        dirInfo.show(fm, BrowserActivity.TAG_DIALOG);
        return true;
    case R.id.search:
        Intent sintent = new Intent(mActivity, SearchActivity.class);
        startActivity(sintent);//w  ww. ja v a2 s.  c om
        return true;
    case R.id.paste:
        final PasteTaskExecutor ptc = new PasteTaskExecutor(mActivity, mCurrentPath);
        ptc.start();
        return true;

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

From source file:com.facebook.samples.musicdashboard.MusicGalleryFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_refresh:
        // User selects refresh, update song content
        fetchMusic();//from www  .  jav  a  2  s  . c o m
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.netpace.expressit.activity.UploadVideoStoryActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        this.onBackPressed();
        return true;

    case R.id.menu_item_video_gallery:
        if (isValidate()) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(titleTextView.getWindowToken(), 0);

            getMediaKeyFromRemoteServer();
        }/*from  w  ww. j a va2s .c o m*/
        return true;

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

From source file:eu.thecoder4.gpl.pleftdroid.PleftDroidActivity.java

@SuppressWarnings("static-access")
@Override/*from www .  j a  va 2  s.c  om*/
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case CREATE_ID:
        if (preferencesComplete()) {
            if (PleftBroker.INSTANCE.isInetConnAvailable(this)) {
                int SC = PleftBroker.INSTANCE.checkServer(AppPreferences.INSTANCE.getPleftServer());
                if (SC != HttpStatus.SC_OK) {
                    int title = R.string.dialog_title_connproblem;
                    int msg = R.string.toast_createapptfailredir;
                    if (SC == PleftBroker.SC_TIMEOUT) {
                        msg = R.string.dialog_msg_connproblem;
                    }
                    new AlertDialog.Builder(this).setTitle(title).setMessage(msg)
                            .setPositiveButton("OK", new OnClickListener() {
                                public void onClick(DialogInterface dif, int arg1) {
                                    // Do nothing
                                    dif.dismiss();
                                }
                            }).show();

                } else {
                    Intent ie = new Intent(this, EditEventActivity.class);
                    startActivityForResult(ie, ACT_CREATE);

                }
            } else {
                new AlertDialog.Builder(this).setTitle(R.string.dialog_title_nonet)
                        .setMessage(R.string.dialog_msg_nonet).setPositiveButton("OK", new OnClickListener() {
                            public void onClick(DialogInterface dif, int arg1) {
                                // Do nothing
                                dif.dismiss();
                            }
                        }).show();
            }
        } else {
            new AlertDialog.Builder(this).setTitle(R.string.dialog_title_settingsreq)
                    .setMessage(R.string.dialog_msg_settingsreq).setPositiveButton("OK", new OnClickListener() {
                        public void onClick(DialogInterface dif, int arg1) {
                            startPreferences();
                        }
                    }).show();
        }
        return true;
    case PREFS_ID:
        startPreferences();
        return true;
    case ABOUT_ID:
        new AboutDialog(this).show();
        return true;

    }
    return super.onOptionsItemSelected(item);
}