Example usage for android.view MenuItem getTitle

List of usage examples for android.view MenuItem getTitle

Introduction

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

Prototype

public CharSequence getTitle();

Source Link

Document

Retrieve the current title of the item.

Usage

From source file:com.google.android.gcm.demo.ui.MainMenu.java

public boolean onOverflowMenuItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.toggle_logs: {
        CharSequence showLogs = mActivity.getString(R.string.show_logs);
        if (showLogs.equals(item.getTitle())) {
            mActivity.toggleLogsView(true);
            item.setTitle(R.string.hide_logs);
            item.setIcon(R.drawable.visibility_off_white);
        } else {//  w  w w  .j  a  va 2  s  .c  o m
            mActivity.toggleLogsView(false);
            item.setTitle(R.string.show_logs);
            item.setIcon(R.drawable.visibility_white);
        }
        return true;
    }
    case R.id.clear_logs: {
        (new Logger(mActivity)).clearLogs();
        return true;
    }
    default:
        return false;
    }
}

From source file:de.nico.ha_manager.activities.Main.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    if (item.getTitle() == getString(R.string.dialog_edit)) {
        editOne(hwArray, pos);/*from  w  ww.j av  a 2  s. c  o  m*/
        return true;
    }
    if (item.getTitle() == getString(R.string.dialog_delete)) {
        deleteOne(hwArray, pos);
        update();
        return true;
    }
    return false;

}

From source file:net.kw.shrdlu.grtgtfs.Activities.MenuListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    final MenuInflater inflater = getMenuInflater();

    // This can be called multiple times, for difference activities, or the
    // action bar & nav drawer. So try process things only once, else the menus are doubled up.

    // Borrow this menu for a moment to expand the nav menu first.
    if (mDrawerItems.size() == 0) {
        inflater.inflate(R.menu.navdrawermenu, menu);
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            mDrawerItems.add(new NavDrawerItem(item.getIcon(), item.getTitle(), item.getItemId()));
        }//from w  ww. ja  va2s  .c  o m
        mNavAdapter.notifyDataSetChanged();
        menu.clear();
    }

    inflater.inflate(R.menu.actionbarmenu, menu);
    return super.onCreateOptionsMenu(menu);
}

From source file:org.codecyprus.android_client.ui.ActivityCategories.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();//from ww w  . j a  v  a2s.  c  om
        return true;
    } else if (getString(R.string.REFRESH).equals(item.getTitle())) {
        refresh();
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.android.cts.uiautomator.Test2DetailFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_title_result);
    builder.setMessage(item.getTitle());
    builder.setPositiveButton(R.string.OK, null);
    AlertDialog diag = builder.create();
    diag.show();//from w ww. j a v  a 2  s.  c  o m
    return super.onOptionsItemSelected(item);
}

From source file:net.granoeste.scaffold.util.TrackerToLog.java

@Override
public void trackOperation(final Fragment fragment, final MenuItem item) {
    if (fragment == null) {
        return;/*  w  w w.  jav  a2s.c om*/
    }
    if (fragment.getActivity() == null) {
        return;
    }
    if (item.getTitle() == null) {
        return;
    }
    track(fragment.getActivity(), makeLogTag(((Object) fragment).getClass()), item.getTitle().toString());
}

From source file:com.cranberrygame.cordova.plugin.optionsmenu.OptionsMenu.java

@Override
public Object onMessage(String id, Object data) {
    //https://github.com/dpogue/cordova-plugin-cambie/blob/master/src/android/Cambie.java
    //http://stackoverflow.com/questions/22403984/get-oncreateoptionsmenu-in-cordova-plugin
    //https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java#L140
    if (id.equals("onCreateOptionsMenu") || id.equals("onPrepareOptionsMenu")) {
        Menu menu = (Menu) data;

        if (this.menus != null) {
            menu.clear();/*from  www.  j  a  v a  2s  .co  m*/

            String[] _menus = this.menus.split(",");
            for (int i = 0; i < _menus.length; i++) {
                menu.add(0, i, 0, _menus[i]);
            }
        }
    } else if (id.equals("onOptionsItemSelected")) {
        MenuItem item = (MenuItem) data;

        //webView.loadUrl(String.format("javascript:cordova.fireDocumentEvent('onMenuSelected', {'menu': '%s'});", item.getTitle()));

        Log.d(LOG_TAG, "onOptionsItemSelected: " + item.getTitle());

        JSONObject result = new JSONObject();
        try {
            result.put("event", "onMenuSelected");
            result.put("message", item.getTitle());
        } catch (JSONException ex) {
        }
        //PluginResult pr = new PluginResult(PluginResult.Status.OK, "onMenuSelected");
        PluginResult pr = new PluginResult(PluginResult.Status.OK, result);
        pr.setKeepCallback(true);
        callbackContextKeepCallback.sendPluginResult(pr);
        //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
        //pr.setKeepCallback(true);
        //callbackContextKeepCallback.sendPluginResult(pr);            
    }

    return null;
}

From source file:am.project.x.business.main.MainActivity.java

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    switch (item.getItemId()) {
    case R.id.main_nav_widgets:
        setTitle(item.getTitle());
        setFragment(TAG_WIDGETS);/*from www  . j a  v  a 2 s  .  com*/
        break;
    case R.id.main_nav_drawables:
        setTitle(item.getTitle());
        setFragment(TAG_DRAWABLES);
        break;
    case R.id.main_nav_others:
        setTitle(item.getTitle());
        setFragment(TAG_OTHERS);
        break;
    case R.id.main_nav_develop:
        setTitle(item.getTitle());
        setFragment(TAG_DEVELOP);
        break;
    case R.id.main_nav_report:
        ContextUtils.openBrowser(this, REPORT);
        break;
    case R.id.main_nav_contact:
        ContextUtils.sendEmail(this, null, null, EMAIL);
        break;
    case R.id.main_nav_about:
        AboutActivity.start(this);
        break;
    }
    mVDrawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.aqnote.app.wifianalyzer.navigation.FragmentItem.java

@Override
public void activate(@NonNull MainActivity mainActivity, @NonNull MenuItem menuItem,
        @NonNull NavigationMenu navigationMenu) {
    NavigationMenuView navigationMenuView = mainActivity.getNavigationMenuView();
    navigationMenuView.setCurrentNavigationMenu(navigationMenu);
    startFragment(mainActivity);//from   w  w w  . j  a v  a  2  s.c  o m
    mainActivity.setTitle(menuItem.getTitle());
    mainActivity.updateSubTitle();
}

From source file:com.spacewarfare.navigation.FragmentItem.java

@Override
public void activate(@NonNull MainActivity mainActivity, @NonNull MenuItem menuItem,
        @NonNull NavigationMenu navigationMenu) {
    NavigationMenuView navigationMenuView = mainActivity.getNavigationMenuView();
    navigationMenuView.setCurrentNavigationMenu(navigationMenu);
    startFragment(mainActivity);/*  w  w w .  j a  v a  2s.c  o m*/
    mainActivity.setTitle(menuItem.getTitle());
    //mainActivity.updateSubTitle();
}