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:net.vexelon.currencybg.app.ui.activities.MainActivity.java

/**
 * Create a new fragment and specify the planet to show based on position.
 *
 * @param menuItem/*from  w ww. j  ava2s.  co  m*/
 * @param clazz
 */
private <T extends AbstractFragment> void selectDrawerItem(MenuItem menuItem, Class<T> clazz) {
    try {
        showFragment(clazz);
        // Highlight the selected item, update the title, and close the
        // drawer
        menuItem.setChecked(true);
        setTitle(menuItem.getTitle());
        drawerLayout.closeDrawers();
    } catch (Exception e) {
        Log.e(Defs.LOG_TAG, "Unknown drawer section!", e);
    }
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();//  w  w  w . jav  a 2s .  co m
        return true;
    } else if (getString(R.string.ENTER_CODE).equals(item.getTitle())) {
        enterCode();
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.crowflying.buildwatch.ConfigurationActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (getString(R.string.menu_request_new_token).equals(item.getTitle())) {
        tracker.trackEvent("configuration", "menu", "req_new_gcm", 0L);

        new GetCloudDeviceMessagingToken()
                .execute(getPreferenceScreen().getSharedPreferences().getString(PREFS_KEY_GCM_SENDER_ID, ""));
        return true;
    }//from ww w  .  java  2s .  co  m
    return false;
}

From source file:com.joaquimley.faboptions.FabOptions.java

private void addButton(Context context, MenuItem menuItem) {
    AppCompatImageView button = mButtonContainer.addButton(context, menuItem.getItemId(), menuItem.getTitle(),
            menuItem.getIcon());/*  w  ww  . j a  v a2  s.  c  o  m*/
    button.setOnClickListener(this);
}

From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getTitle() != null && item.getTitle().equals(getActivity().getString(R.string.action_reply))) {

        onParentReply();/*from w  w  w .ja  va 2  s  . c  o m*/
        return true;
    }

    return false;
}

From source file:net.kjmaster.cookiemom.MainActivity.java

@OptionsItem({ R.id.menu_personal, R.id.menu_cookie_mom })
void onProfileSwitch(MenuItem item) {
    if (item.getTitle().toString().equals(getString(R.string.Personal))) {
        iSettings.dbName().put(iSettings.dbPersonalName().get());
        main.switchDb(iSettings.dbPersonalName().get());
        afterViews();//from www.j  a  va 2  s .  c o  m
        item.setTitle(R.string.cookie_mom);
    } else {
        iSettings.dbName().put(iSettings.dbCookieMomName().get());
        main.switchDb(iSettings.dbCookieMomName().get());
        afterViews();
        item.setTitle(R.string.Personal);
    }

}

From source file:com.cullaboration.userhookdemo.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override//from   w w w .ja  va2  s.  co m
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (staticPages.containsKey(item.getTitle())) {

        UHPage page = staticPages.get(item.getTitle());
        Intent intent = new Intent(this, UHHostedPageActivity.class);
        intent.putExtra(UHHostedPageActivity.TYPE_PAGE, page);
        startActivity(intent);

    } else if (id == R.id.nav_feedback) {
        clickedFeedback();

    } else if (id == R.id.nav_rate) {

        UHMessageMetaButton button1 = new UHMessageMetaButton();
        button1.setTitle("Yes");
        button1.setOnClickListener(new UHMessageMetaButton.OnClickListener() {
            @Override
            public void onClick() {
                showRatingPrompt();
            }
        });

        UHMessageMetaButton button2 = new UHMessageMetaButton();
        button2.setTitle("No");
        button2.setOnClickListener(new UHMessageMetaButton.OnClickListener() {
            @Override
            public void onClick() {
                showFeedbackPrompt();
            }
        });

        UserHook.displayPrompt("We are glad you downloaded the app. Are you enjoying using it?", button1,
                button2);

    } else if (id == R.id.nav_clear_session) {

        clearSession();

    } else if (id == R.id.nav_clear_user) {

        clearUser();

    }

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

From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.v(TAG, "onOptionsItemSelected: item = " + item.getItemId() + ": " + item.getTitle());
    if (getActivity().isFinishing()) {
        Log.w(TAG, "User clicked on a menu item while the activity is finishing.  Surely a monkey is involved");
        return true;
    }/* w  w  w .  j a va 2s  .  co m*/
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(getActivity());
        return true;
    case R.id.action_share_meeting:
        mMeetings.export(mMeeting.getId());
        return true;
    case R.id.action_charts_meeting:
        MeetingChartActivity.start(getContext(), mMeeting.getId());
        return true;
    case R.id.action_delete_meeting:
        mMeetings.confirmDelete(mMeeting);
        return true;
    default:
        super.onOptionsItemSelected(item);
        return false;
    }
}

From source file:com.example.mpodera.tourismapp.MainActivity.java

private void setNavigationDrawer() {
    mTitle = mDrawerTitle = getTitle();/*from  www  . j  a v  a 2 s.c o  m*/
    dLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navView = (NavigationView) findViewById(R.id.navigation);
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            dLayout, /* DrawerLayout object */
            R.drawable.ic_menu_white_24dp, /* nav drawer image to replace 'Up' caret */
            R.string.abierto, /* "open drawer" description for accessibility */
            R.string.cerrado /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            if (navView.getMenu().findItem(menuItemD).isChecked()) {
                getSupportActionBar().setTitle(mTitle);
            } else {
                navView.getMenu().findItem(menuItemD).setChecked(false);
                getSupportActionBar().setTitle(R.string.aC);
            }
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            //getSupportActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    dLayout.setDrawerListener(mDrawerToggle);
    navView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            if (menuItem.isChecked())
                menuItem.setChecked(false);
            else
                menuItem.setChecked(true);
            menuItemD = menuItem.getItemId();
            selectItem(menuItem.getItemId());
            setTitle(menuItem.getTitle());
            return false;
        }
    });
}

From source file:com.google.android.apps.forscience.whistlepunk.MainActivity.java

private void adjustActivityForSelectedItem(int itemId) {
    MenuItem menu = mNavigationView.getMenu().findItem(itemId);
    setTitle(getString(R.string.title_activity_main, menu.getTitle()));
}