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.reichholf.dreamdroid.activities.VirtualRemoteActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_LAYOUT:
        setLayout(!mQuickZap);/*from   ww  w. java2  s.  co m*/
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }

}

From source file:MainActivity.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();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }//w  w w  .  j a  v a 2  s .c o m

    return super.onOptionsItemSelected(item);
}

From source file:com.facebook.samples.socialcafe.MenuFragmentActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_logout:
        ((SocialCafeApplication) getActivity().getApplication()).asyncRunner.logout(getActivity(),
                new LogoutRequestListener());
        return true;
    default://  w  ww. ja  v a2  s. c om
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.vmihalachi.turboeditor.activity.SelectFileActivity.java

/**
 * {@inheritDoc}/*from  w ww  . j ava  2s. c om*/
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int i = item.getItemId();
    if (i == R.id.im_button) {
        if (wantAFolder) {
            returnData(currentFolder);
        } else if (wantAFile) {
            returnData("");
        }
    } else if (i == R.id.im_new_file) {
        final EditDialogFragment dialogFrag = EditDialogFragment
                .newInstance(EditDialogFragment.Actions.NewLocalFile);
        dialogFrag.show(getFragmentManager().beginTransaction(), "dialog");
    }
    return super.onOptionsItemSelected(item);
}

From source file:codepath.watsiapp.activities.BaseFragmentActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final int menuItemId = item.getItemId();
    if (menuItemId == R.id.action_profileView) {
        Util.showMyProfileActivity(this);
    }//from   w w w . j ava2s.  c  o  m
    if (menuItemId == R.id.action_logout) {
        logout();
        logout.setVisible(false);
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.makotosan.vimeodroid.ManageTransfersActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    if (item.getItemId() == R.id.contextmenu_cancel) {
        Transfer transfer = getModel(info.position);
        AbortableHttpRequest request = transfer.getAbortableRequest();
        if (request != null) {
            request.abort();//from w ww  .  j a  va  2  s.c o  m
        }
    }

    return true;
}

From source file:com.pixellostudio.qqdroid.BaseQuote.java

public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case 1://from w  w  w.  jav a  2 s. c  o  m
        AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

        Spanned quote = Html.fromHtml((String) view.getAdapter().getItem(menuInfo.position));

        Intent i = new Intent(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_TEXT,
                getBaseContext().getText(R.string.quotefrom) + " " + name + " : " + quote);
        i.setType("text/plain");
        startActivity(Intent.createChooser(i, this.getText(R.string.share)));

        break;
    default:
        return super.onContextItemSelected(item);
    }
    return true;
}

From source file:za.co.neilson.alarm.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    String url = null;//from w w  w  . j  a  v  a 2s. c  o m
    Intent intent = null;
    switch (item.getItemId()) {
    case R.id.menu_item_join:
        startDialog();
        break;
    case R.id.menu_item_new:

        startAlarmPreferencesActivity();
        break;
    case R.id.menu_item_rate:
        url = "market://details?id=" + getPackageName();
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Couldn't launch the market", Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.menu_item_website:
        url = "http://www.neilson.co.za";
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Couldn't launch the website", Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.menu_item_report:

        url = "https://github.com/SheldonNeilson/Android-Alarm-Clock/issues";
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Couldn't launch the bug reporting website", Toast.LENGTH_LONG).show();
        }

        /*
        Intent send = new Intent(Intent.ACTION_SENDTO);
        String uriText;
                
        String emailAddress = "dontusemyemailaddress@yourdomain.com";
        String subject = R.string.app_name + " Bug Report";
        String body = "Debug:";
        body += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")";
        body += "\n OS API Level: " + android.os.Build.VERSION.SDK_INT;
        body += "\n Device: " + android.os.Build.DEVICE;
        body += "\n Model (and Product): " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";
        body += "\n Screen Width: " + getWindow().getWindowManager().getDefaultDisplay().getWidth();
        body += "\n Screen Height: " + getWindow().getWindowManager().getDefaultDisplay().getHeight();
        body += "\n Hardware Keyboard Present: " + (getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS);
                
        uriText = "mailto:" + emailAddress + "?subject=" + subject + "&body=" + body;
                
        uriText = uriText.replace(" ", "%20");
        Uri emalUri = Uri.parse(uriText);
                
        send.setData(emalUri);
        startActivity(Intent.createChooser(send, "Send mail..."));
        */
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.idlesoft.android.apps.github.activities.NewsFeed.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case 1:// w  w w  . j a v a 2  s  .co  m
        mEditor.clear().commit();
        final Intent intent = new Intent(NewsFeed.this, Hubroid.class);
        startActivity(intent);
        finish();
        return true;
    case 2:
        final File root = Environment.getExternalStorageDirectory();
        if (root.canWrite()) {
            final File hubroid = new File(root, "hubroid");
            if (!hubroid.exists() && !hubroid.isDirectory()) {
                return true;
            } else {
                hubroid.delete();
                return true;
            }
        }
    }
    return false;
}

From source file:com.microsoft.onedrive.apiexplorer.DeltaFragment.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_refresh:
        refresh();//  w  w w  .  j a  v  a 2s  .c  o m
        return true;
    case R.id.reset_token:
        resetToken();
        return true;
    case R.id.reset_all_tokens:
        resetAllTokens();
        return true;
    default:
        return false;
    }
}