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:fr.cph.stock.android.activity.ChartActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    MainTask mainTask;// ww  w .j a  v  a2s  .  c o m
    switch (item.getItemId()) {
    case R.id.action_logout:
        mainTask = new MainTask(this, UrlType.LOGOUT, null);
        mainTask.execute((Void) null);
        return true;
    case R.id.refresh:
        menuItem = item;
        menuItem.setActionView(R.layout.progressbar);
        menuItem.expandActionView();
        tracker.sendEvent("Buttons Category", "Reload", "", 0L);
        mainTask = new MainTask(this, UrlType.RELOAD, null);
        mainTask.execute((Void) null);
        return true;
    case android.R.id.home:
        finish();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.manning.androidhacks.hack040.ImageGridFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.clear_cache:
        final ImageCache cache = mImageWorker.getImageCache();
        if (cache != null) {
            mImageWorker.getImageCache().clearCaches();
            // DiskLruCache.clearCache(getActivity(), ImageFetcher.HTTP_CACHE_DIR);
            Toast.makeText(getActivity(), R.string.clear_cache_complete, Toast.LENGTH_SHORT).show();
        }//  www. j  a  v  a2  s . co  m
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.scigames.registration.Registration5EmailActivity.java

/**
 * Called when a menu item is selected.//w w w.ja v  a2s .  c om
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case BACK_ID:
        finish();
        return true;
    case CLEAR_ID:
        email.setText("");
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:fr.bmartel.android.iotf.app.BaseActivity.java

/**
 * process menu item selected// w w  w.  j  ava2  s  . c  om
 *
 * @param menuItem
 * @param mDrawer
 * @param context
 */
protected void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context) {

    switch (menuItem.getItemId()) {
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "kiruazoldik92@gmail.com", null));
        intent.putExtra(Intent.EXTRA_SUBJECT, "iotf Issue");
        intent.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
        context.startActivity(Intent.createChooser(intent, "Report a problem"));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog();
        android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
        d.show(manager, "open_source_components");
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:com.tk.httpClientErp.headmandraw.DrawsListActivity.java

/**
 * /*from   w w  w .  j  av a  2s  .c  o  m*/
 */
@SuppressWarnings("unchecked")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    switch (item.getItemId()) // Id
    {
    case R.id.menu_item_buslist_yes:
        HashMap<String, Object> hashMapsYES = MyStore.subAndDel(MyStore.drawList);
        List<JSONObject> submitJsonArrayYES = (List<JSONObject>) hashMapsYES.get("submitJsonArray");
        List<HashMap<String, Object>> delListYES = (List<HashMap<String, Object>>) hashMapsYES.get("delList");
        params.add(new BasicNameValuePair("submitJsonArray", submitJsonArrayYES.toString()));
        String reultString = null;
        try {
            reultString = HttpClientUtil.postRequest("/android.do?method=updateDraws", params,
                    MyStore.sessionID);
        } catch (TimeoutException e) {
            e.printStackTrace();
            DrawsListActivity.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(DrawsListActivity.this, MyStore.TIMEOUTLOGIN, Toast.LENGTH_SHORT).show();
                }
            });
        }
        reultString = HttpClientUtil.callBackSuccOrFail(reultString, "resualt");
        if (HttpClientUtil.reSUCCorFAILE)
            MyStore.drawList.removeAll(delListYES);
        final String MSG = reultString;
        DrawsListActivity.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(DrawsListActivity.this, MSG, Toast.LENGTH_SHORT).show();
            }
        });
        ((MySimpleAdapter) getListAdapter()).notifyDataSetChanged();
        break;
    case R.id.menu_item_buslist_selectec_or_cancle:
        MyStore.selectORcancle(mResult, "mResult", MyStore.drawList);
        mResult = mResult == true ? false : true;
        ((MySimpleAdapter) getListAdapter()).notifyDataSetChanged();
        break;
    }
    return true;
}

From source file:com.android.example.devsummit.archdemo.view.activity.FeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        startActivity(SettingsActivity.intentFor(this));
        return true;
    }/*from   w  w  w .  j  ava2  s . c o  m*/

    return super.onOptionsItemSelected(item);
}

From source file:net.olejon.mdapp.DonateActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home: {
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }/* w ww .j  a v a2  s . c  om*/
    case R.id.donate_menu_reset: {
        resetDonations();
        return true;
    }
    default: {
        return super.onOptionsItemSelected(item);
    }
    }
}

From source file:com.example.android.bluetoothchat.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_toggle_log:
        mLogShown = !mLogShown;/*from  w  w w  . j av a2  s .  c  o m*/
        ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
        if (mLogShown) {
            output.setDisplayedChild(1);
        } else {
            output.setDisplayedChild(0);
        }
        supportInvalidateOptionsMenu();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:app.com.example.android.sunshine.ForecastFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_refresh) {
        FetchWeatherTask task = new FetchWeatherTask();
        task.execute(94043);/*from   w  w  w. j a  v  a 2  s .  c  o  m*/

        return true;
    } else if (item.getItemId() == R.id.action_settings) {
        Intent settingsIntent = new Intent(getActivity(), SettingsActivity.class);
        //detailIntent.putExtra(Intent.EXTRA_TEXT,forecastAdapter.getItem(position));
        startActivity(settingsIntent);
    }
    return super.onOptionsItemSelected(item);

}

From source file:app.hacked.ProjectListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_add_project: {
        //LaunchAddProject();
        startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://www.hackerleague.org/hackathons/hacked/hacks")));
        return true;
    }/* ww  w  .  j  ava  2  s  . c om*/

    default:
        return false;

    }
}