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.gmail.boiledorange73.ut.map.MapActivityBase.java

/** Called when one of the menu item is selected. */
@Override//from ww  w.  ja  v  a 2  s  .  c  o m
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch (item.getItemId()) {
    case ID_ZOOM:
        ZoomState zoomState = this.getCurrentZoomState();
        if (zoomState != null && zoomState.minzoom >= 0 && zoomState.maxzoom >= zoomState.minzoom) {
            AlertDialogHelper.createSequentialDialog(this, Messages.getString("W_ZOOM"), zoomState.minzoom,
                    zoomState.maxzoom, 1, zoomState.currentzoom, 0,
                    new AlertDialogHelper.OnChoiceListener<Integer>() {
                        @Override
                        public void onChoice(DialogInterface dialog, Integer item) {
                            MapActivityBase.this.restoreMapState(null, null, null, item);
                        }
                    }).show();
        }
        return true;
    case ID_MAPTYPE:
        if (this.mMaptypeList != null && this.mMaptypeList.size() > 0) {
            AlertDialogHelper.<ValueText<String>>showChoice(this, item.getTitle().toString(), this.mMaptypeList,
                    0, new AlertDialogHelper.OnChoiceListener<ValueText<String>>() {
                        @Override
                        public void onChoice(DialogInterface dialog, ValueText<String> item) {
                            if (item != null && item.getValue() != null) {
                                MapActivityBase.this.restoreMapState(item.getValue(), null, null, null);
                            }
                        }
                    });
        }
        return true;
    case ID_MYLOCATION:
        this.startLocationService(this.isHighAccuracy());
        return true;
    case ID_MORE_CLEARCACHE:
        AlertDialogHelper.showConfirmationDialog(this, Messages.getString("W_CLEARCACHE"),
                Messages.getString("P_CONFIRM_CLEARCACHE"), android.R.drawable.ic_dialog_alert,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (MapActivityBase.this.mHandler != null) {
                            MapActivityBase.this.mHandler.post(new Runnable() {
                                @Override
                                public void run() {
                                    MapActivityBase.this.clearCache();
                                }
                            });
                        } else {
                            MapActivityBase.this.clearCache();
                        }
                    }
                });
        return true;
    case ID_MORE_EXIT:
        this.showExitConfirmation();
        return true;
    case ID_MORE_PREFERENCES:
        Class<? extends Activity> preferenceActivityClass = this.getPreferenceActivityClass();
        if (preferenceActivityClass != null) {
            // saves current map state into this.mMapState
            this.mLatestMapState = this.getCurrentMapState();
            this.startActivityForResult(new Intent(this, preferenceActivityClass), RC_PREFERENCES);
        }
        return true;
    case ID_MORE_EXTERNALMAP:
        this.showExternalMap();
        return true;
    case ID_MORE_REMOVEDOWNLOADEDFILES:
        AlertDialogHelper.showConfirmationDialog(this, Messages.getString("W_REMOVEDOWNLOADEDFILES"),
                Messages.getString("P_CONFIRM_REMOVEDOWNLOADEDFILES"), android.R.drawable.ic_dialog_alert,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        MapActivityBase.this.mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                MapActivityBase.this.removeDownloadedFiles();
                                System.exit(0);
                            }
                        });
                    }
                });
        return true;
    case ID_MORE_ABOUT:
        this.showAbout();
        return true;
    case ID_GEOCODER:
        Class<? extends Activity> geocoderClass = this.getGeocoderActivityClass();
        if (geocoderClass != null) {
            Intent intent = new Intent(this, geocoderClass);
            this.startActivityForResult(intent, RC_GEOCODER);
        }
    }
    return false;
}

From source file:com.vuze.android.remote.fragment.TorrentListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (AndroidUtils.DEBUG_MENU) {
        Log.d(TAG, "onOptionsItemSelected " + item.getTitle());
    }//w  ww . j  av  a2s .  c  om
    return handleFragmentMenuItems(item.getItemId()) || super.onOptionsItemSelected(item);
}

From source file:com.ekasoft.promoexito.MyActivity.java

public void onGroupItemClick(MenuItem item) {
    int id = item.getItemId();

    MenuItem searchItem = menu.findItem(com.ekasoft.promoexito.R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.clearFocus();//from  w w  w . j  a  v a2 s . c  o  m

    String order = "";
    switch (id) {

    case com.ekasoft.promoexito.R.id.submenu_by_more_recent:
        order = "dateCreated desc";
        break;

    case com.ekasoft.promoexito.R.id.submenu_by_saving_min:
        order = "saving_int asc";
        break;

    case com.ekasoft.promoexito.R.id.submenu_by_saving_max:
        order = "saving_int desc";
        break;

    case com.ekasoft.promoexito.R.id.submenu_by_price_min:
        order = "price_int asc";
        break;

    case com.ekasoft.promoexito.R.id.submenu_by_price_max:
        order = "price_int desc";
        break;

    case com.ekasoft.promoexito.R.id.submenu_by_desc_min:
        order = "offert_int desc";
        break;

    case com.ekasoft.promoexito.R.id.submenu_by_desc_max:
        order = "offert_int asc";
        break;

    case com.ekasoft.promoexito.R.id.submenu_a_z:
        order = "name asc";
        break;

    case com.ekasoft.promoexito.R.id.submenu_z_a:
        order = "name desc";
        break;

    case android.R.id.home:
        break;
    }

    invalidateOptionsMenu();
    Settings.set(this, "promo_order_list", order);
    Settings.set(this, "promo_order", "true");

    listPromo = new FragmentListPromo();
    getSupportFragmentManager().beginTransaction()
            .replace(com.ekasoft.promoexito.R.id.fragment_container, listPromo).commit();

    Toast.makeText(MyActivity.this, "" + item.getTitle(), Toast.LENGTH_SHORT).show();
}

From source file:com.aegamesi.steamtrade.MainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
    switch (menuItem.getItemId()) {
    case R.id.nav_friends:
        browseToFragment(new FragmentFriends(), true);
        break;/*from  www.ja v  a  2  s .  c o m*/
    case R.id.nav_inventory:
        browseToFragment(new FragmentInventory(), true);
        break;
    case R.id.nav_offers:
        browseToFragment(new FragmentOffersList(), true);
        break;
    case R.id.nav_games:
        browseToFragment(new FragmentLibrary(), true);
        break;
    case R.id.nav_market: {
        FragmentWeb.openPage(this, "https://steamcommunity.com/market/", true);
        break;
    }
    case R.id.nav_store: {
        FragmentWeb.openPageWithTabs(this, null, true, getResources().getStringArray(R.array.store_tabs),
                getResources().getStringArray(R.array.store_urls));
        break;
    }
    case R.id.nav_browser:
        browseToFragment(new FragmentWeb(), true);
        break;
    case R.id.nav_settings:
        browseToFragment(new FragmentSettings(), true);
        break;
    case R.id.nav_about:
        browseToFragment(new FragmentAbout(), true);
        break;
    case R.id.nav_signout:
        disconnectWithDialog(this, getString(R.string.signingout));
        return true;
    default:
        return true;
    }

    //menuItem.setChecked(true);
    toolbar.setTitle(menuItem.getTitle());
    return true;
}

From source file:com.reallynourl.nourl.fmpfoldermusicplayer.ui.activity.MainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    FragmentManager fm = getFragmentManager();
    IMainContent fragment = (IMainContent) fm.findFragmentByTag(CONTENT_FRAGMENT_TAG);
    if (fragment != null)
        mActiveContent = fragment;/*w ww  . j  a  v  a2  s .  com*/
    switch (id) {
    case R.id.nav_file_browser:
        if (mActiveContent == null || !mActiveContent.getName().equals(FileBrowserFragment.NAME)
                || !mActiveContent.isCreated()) {
            if (mActiveContentSavedName == null || !mActiveContentSavedName.equals(FileBrowserFragment.NAME)) {
                loadFragmentToContent(new FileBrowserFragment());
                Log.d("Navigation", "Loading file browser fragment!");
            }
        }
        break;
    case R.id.nav_settings:
        if (mActiveContent == null || !mActiveContent.getName().equals(SettingsFragment.NAME)) {
            if (mActiveContentSavedName == null || !mActiveContentSavedName.equals(SettingsFragment.NAME)) {
                loadFragmentToContent(new SettingsFragment());
                Log.d("Navigation", "Loading Settings fragment");
            }
        }
        break;
    case R.id.nav_currently_playing:
        if (mActiveContent == null || !mActiveContent.getName().equals(MusicPlayingFragment.NAME)) {
            if (mActiveContentSavedName == null || !mActiveContentSavedName.equals(MusicPlayingFragment.NAME)) {
                loadFragmentToContent(new MusicPlayingFragment());
                Log.d("Navigation", "Loading Player fragment");
            }
        }
        break;
    default:
        Log.e("Navigation", "Navigation button has no action, id: " + id + " text: " + item.getTitle());
    }

    mActiveContentSavedName = null;
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

public void OptionUnSelect(int sel_1) {
    MenuItem mi = menu.findItem(sel_1);
    String tmp = (String) mi.getTitle();
    mi.setTitle(tmp.replace(">", "").replace("<", ""));
}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

public void OptionSelect(int sel_1, int sel_2, int sel_3, int sel_4, int sel_5) {
    MenuItem mi = menu.findItem(sel_1);
    String tmp = (String) mi.getTitle();
    if (tmp.indexOf('>') < 0) {
        mi.setTitle(">" + mi.getTitle() + "<");
    }//from www . ja  v a  2  s .  co m
    OptionUnSelect(sel_2);
    OptionUnSelect(sel_3);
    OptionUnSelect(sel_4);
    OptionUnSelect(sel_5);
}

From source file:github.daneren2005.dsub.fragments.SubsonicFragment.java

protected void recreateContextMenu(Menu menu) {
    List<MenuItem> menuItems = new ArrayList<MenuItem>();
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        if (item.isVisible()) {
            menuItems.add(item);/*from  www  .  j av  a  2  s.co  m*/
        }
    }
    menu.clear();
    for (int i = 0; i < menuItems.size(); i++) {
        MenuItem item = menuItems.get(i);
        menu.add(tag, item.getItemId(), Menu.NONE, item.getTitle());
    }
}

From source file:com.simadanesh.isatis.ScreenSlideActivity.java

private void showfilterMenu() {
    View p = findViewById(R.id.anchorer);
    progressbar.setVisibility(View.GONE);

    final PopupMenu popup = new PopupMenu(this, p);
    //Inflating the Popup using xml file  
    popup.getMenuInflater().inflate(R.menu.filter, popup.getMenu());
    for (int i = 0; i < popup.getMenu().size(); i++) {
        MenuItem item = popup.getMenu().getItem(i);
        String countstr = "0";
        switch (item.getItemId()) {
        case R.id.filter_no_filter:
            countstr = countFilterNofilter();
            break;
        case R.id.filter_no_data:
            countstr = countFilterNodata();
            break;
        case R.id.filter_valid_reading:
            countstr = countFilterValid();
            break;
        case R.id.filter_hilow:
            countstr = countFilterHilow();
            break;
        case R.id.filter_maneh:
            countstr = countFilterManeh();

            break;
        case R.id.filter_inspection:
            countstr = countFilterInspection();
            break;
        case R.id.filter_register_field:
            countstr = countFilterRegisterField();
            break;
        case R.id.filter_not_register_field:
            countstr = countFilterRegisterNotField();
            break;

        }//  w w w .j av a2  s .  c  o m
        item.setTitle(item.getTitle() + "\t" + countstr);
    }

    //registering popup with OnMenuItemClickListener  
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.filter_no_filter:
                filterNofilter();
                break;
            case R.id.filter_no_data:
                filterNodata();
                break;
            case R.id.filter_valid_reading:
                filterValid();
                break;
            case R.id.filter_hilow:
                filterHilow();
                break;
            case R.id.filter_maneh:
                //filterManeh();
                showManehMenu();
                break;
            case R.id.filter_inspection:
                filterInspection();
                break;
            case R.id.filter_register_field:
                filterRegisterField();
                break;
            case R.id.filter_not_register_field:
                filterRegisterNotField();
                break;

            }
            return true;
        }
    });

    final Handler handler1 = new Handler();
    progressbar.setVisibility(View.GONE);
    //android.R.attr.progressBarStyleLarge
    handler1.postDelayed(new Runnable() {
        @Override
        public void run() {
            popup.show();
        }
    }, 100);
}

From source file:com.zen.androidhtmleditor.AHEActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (AppIsLicensed == false) {
        return false;
    }/*  w w w .  j  av a  2  s  . com*/

    if (item.getTitle().toString() == "No Accounts") {
        return false;
    }

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    String currentServers = settings.getString("Accounts", "");
    if (currentServers.equals("")) {
        return false;
    } else {
        Gson gson = new Gson();
        SearchResponse response = gson.fromJson(currentServers, SearchResponse.class);
        List<Result> results = response.data;

        Result l = results.get(item.getOrder());

        if (l.serverName != "" && l.userName != "" && l.port.trim() != "") {
            connectedTo = item.getOrder();

            SharedPreferences.Editor editor = settings.edit();
            editor.putInt("connectedTo", connectedTo);
            editor.commit();

            if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) {
                new MyFetchTask(l.serverName, l.userName, l.passWord, "folder", folderPath, l.sftp, l.port)
                        .execute();
            } else if (l.sftp.equals("3")) {
                new FetchSSLTask(l.serverName, l.userName, l.passWord, "folder", folderPath, l.sftp, l.port)
                        .execute();
            }
            return true;
        } else {
            return false;
        }

    }

}