Example usage for android.support.v4.view MenuItem setTitle

List of usage examples for android.support.v4.view MenuItem setTitle

Introduction

In this page you can find the example usage for android.support.v4.view MenuItem setTitle.

Prototype

@Override
    MenuItem setTitle(int title);

Source Link

Usage

From source file:com.flipzu.flipzu.Profile.java

@Override
public void onUserReceived(FlipUser user) {
    this.mUser = user;
    ((TextView) findViewById(R.id.username)).setText(user.getUsername());
    ((TextView) findViewById(R.id.full_name)).setText(user.getFullname());
    ImageView bg = (ImageView) findViewById(R.id.user_avatar);
    bg.setOnClickListener(new OnClickListener() {

        @Override//from  www .j  av a2s. c om
        public void onClick(View v) {
            Intent i = new Intent(Profile.this, ProfileImage.class);
            i.putExtra("imageUrl", mUser.getAvatarUrl());
            startActivity(i);
        }
    });
    UrlImageViewHelper.setUrlDrawable(bg, user.getAvatarUrl(), R.drawable.icon_sq);
    frag.setUser(user);
    if (mMenu != null) {
        MenuItem item = mMenu.findItem(MENU_ITEM_FOLLOW);

        if (user.isFollowing()) {
            item.setIcon(R.drawable.friends_active);
            item.setTitle(R.string.unfollow);
        } else {
            item.setIcon(R.drawable.friends);
            item.setTitle(R.string.follow);
        }
    }
}

From source file:com.flipzu.flipzu.Player.java

@Override
public void onUnfollowReceived(boolean ret) {
    debug.logV(TAG, "onUnfollowReceived " + ret);
    if (ret) {//from  ww w.ja  v  a 2s . c o m
        MenuItem item = mMenu.findItem(MENU_ITEM_FOLLOW);
        item.setIcon(R.drawable.friends);
        item.setTitle(R.string.follow);
        mUser.setFollowing(false);
    }
}

From source file:com.flipzu.flipzu.Player.java

@Override
public void onFollowReceived(boolean ret) {
    debug.logV(TAG, "onFollowReceived " + ret);
    if (ret) {/*from  w  w  w  .jav a2  s.  co  m*/
        MenuItem item = mMenu.findItem(MENU_ITEM_FOLLOW);
        item.setIcon(R.drawable.friends_active);
        item.setTitle(R.string.unfollow);
        mUser.setFollowing(true);
    }
}

From source file:com.flipzu.flipzu.Player.java

@Override
public void onUserReceived(FlipUser user) {
    debug.logV(TAG, "onUserReceived, got " + user.getUsername());

    mUser = user;//from  w  w  w . j  a v a 2 s.c o m

    if (mMenu != null) {
        MenuItem item = mMenu.findItem(MENU_ITEM_FOLLOW);

        if (user.isFollowing()) {
            item.setIcon(R.drawable.friends_active);
            item.setTitle(R.string.unfollow);
        } else {
            item.setIcon(R.drawable.friends);
            item.setTitle(R.string.follow);
        }
    }
}

From source file:ca.mudar.mtlaucasou.BaseMapActivity.java

/**
 * Toggle display of both fragments, depending on landscape/portrait
 * layouts. Also toggle the actionbar button icon. {@inheritDoc}
 *//*from w w  w .  jav  a2s  .c o  m*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    FragmentManager fm = getSupportFragmentManager();
    BaseMapFragment fragmentMap = (BaseMapFragment) fm.findFragmentByTag(Const.TAG_FRAGMENT_MAP);
    Fragment fragmentList = fm.findFragmentByTag(Const.TAG_FRAGMENT_LIST);

    if (item.getItemId() == R.id.actionbar_toggle_list) {

        View root = findViewById(R.id.map_root_landscape);
        boolean isTablet = (root != null);

        FragmentTransaction ft = fm.beginTransaction();

        if ((fragmentMap == null) || (fragmentList == null)) {
            return false;
        }

        if (fragmentList.isVisible()) {
            /**
             * List is visible: hide it.
             */
            ft.hide(fragmentList);
            isHiddenList = true;
            if (!isTablet) {
                /**
                 * In portrait layout, we also have to show the hidden map.
                 */
                ft.show(fragmentMap);
            }

            /**
             * List is now hidden: Set the actionbar button to view_list.
             */
            item.setIcon(getResources().getDrawable(R.drawable.ic_actionbar_view_list));
            item.setTitle(R.string.menu_view_list);
        } else {
            /**
             * List is not visible: show it.
             */
            ft.show(fragmentList);
            isHiddenList = false;
            if (!isTablet) {
                /**
                 * In portrait layout, we also have to hide the visible map.
                 */
                ft.hide(fragmentMap);
            }

            /**
             * Map is now hidden: Set the actionbar button to view_map.
             */
            item.setIcon(getResources().getDrawable(R.drawable.ic_actionbar_view_map));
            item.setTitle(R.string.menu_view_map);
        }
        ft.commit();

        return true;
    } else if (item.getItemId() == R.id.menu_map_mylocation) {
        /**
         * Center map on user location.
         */

        fragmentMap.setMapCenterOnLocation(((AppHelper) getApplicationContext()).getLocation());

        return true;
    } else if (item.getItemId() == R.id.menu_map_find_from_name) {
        /**
         * Search location by postal code (or address) and center map on
         * location if found) by Geocode.
         */
        showPostalCodeDialog();
        return true;
    } else {
        ActivityHelper mActivityHelper = ActivityHelper.createInstance(this);

        return mActivityHelper.onOptionsItemSelected(item, indexSection) || super.onOptionsItemSelected(item);
    }
}