当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem.setTitle方法代码示例

本文整理汇总了Java中android.view.MenuItem.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setTitle方法的具体用法?Java MenuItem.setTitle怎么用?Java MenuItem.setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.MenuItem的用法示例。


在下文中一共展示了MenuItem.setTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_main, menu);
    if (isPlaylistPage()) {
        menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
    }
    Fragment currentFragment = getCurrentFragment();
    if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment && currentFragment.isAdded()) {
        AbsLibraryPagerRecyclerViewCustomGridSizeFragment absLibraryRecyclerViewCustomGridSizeFragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;

        MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
        if (Util.isLandscape(getResources())) {
            gridSizeItem.setTitle(R.string.action_grid_size_land);
        }
        setUpGridSizeMenu(absLibraryRecyclerViewCustomGridSizeFragment, gridSizeItem.getSubMenu());

        menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
        menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());
    } else {
        menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
        menu.removeItem(R.id.action_grid_size);
        menu.removeItem(R.id.action_colored_footers);
    }
    colorToolbar();
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:27,代码来源:LibraryFragment.java

示例2: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);
    if (item == mItemFace50)
        setMinFaceSize(0.5f);
    else if (item == mItemFace40)
        setMinFaceSize(0.4f);
    else if (item == mItemFace30)
        setMinFaceSize(0.3f);
    else if (item == mItemFace20)
        setMinFaceSize(0.2f);
    else if (item == mItemType) {
        int tmpDetectorType = (mDetectorType + 1) % mDetectorName.length;
        item.setTitle(mDetectorName[tmpDetectorType]);
        setDetectorType(tmpDetectorType);
    }
    return true;
}
 
开发者ID:uelordi01,项目名称:Android-opencv-native-samples,代码行数:19,代码来源:FdActivity.java

示例3: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (mPresenter.getIssue() != null) {
        getMenuInflater().inflate(R.menu.menu_issue_detail, menu);
        boolean isCanToggle = AppData.INSTANCE.getLoggedUser().getLogin()
                .equals(mPresenter.getIssue().getUser().getLogin()) ||
                AppData.INSTANCE.getLoggedUser().getLogin()
                        .equals(mPresenter.getIssue().getRepoAuthorName());
        boolean isOpen = mPresenter.getIssue().getState().equals(Issue.IssueState.open);
        if (isCanToggle) {
            MenuItem item = menu.findItem(R.id.action_issue_toggle);
            item.setTitle(isOpen ? R.string.close : R.string.reopen);
        } else {
            menu.removeItem(R.id.action_issue_toggle);
        }
    }
    return true;
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:19,代码来源:IssueDetailActivity.java

示例4: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_main, menu);

    for (int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        switch (menuItem.getItemId()) {
            case R.id.action_share:
                menuItem.setTitle(StringsManager.getString("menu_share_app"));
                break;
            case R.id.action_language:
                menuItem.setTitle(StringsManager.getString("menu_language"));
                break;
        }
    }

    if (mFragment instanceof ShareFragment) {
        menu.findItem(R.id.action_share).setVisible(true);
        menu.findItem(R.id.action_language).setVisible(false);
    } else {
        menu.findItem(R.id.action_share).setVisible(false);
        menu.findItem(R.id.action_language).setVisible(true);
    }
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:27,代码来源:MainActivity.java

示例5: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case R.id.action_music:
            MusicDialog dialog = MusicDialog.newInstance();
            dialog.show(getSupportFragmentManager(), "MusicDialogFragment");
            return true;
        case R.id.action_preview:
            if (mTextLoaded) {
                if (!mPreviewMode) {
                    showPreviewMode();
                    item.setIcon(R.drawable.ic_edit);
                    item.setTitle(R.string.action_edit);
                } else {
                    showEditMode();
                    item.setIcon(R.drawable.ic_preview);
                    item.setTitle(R.string.action_preview);
                }
            } else {
                Toast.makeText(this, R.string.preview_error_msg, Toast.LENGTH_LONG).show();
            }
            return true;
        case R.id.action_save:
            saveDocument(new Callbacks.FinishCallback<Void>() {
                @Override
                public void onFinish(Void result) {
                    Toast.makeText(EditDocActivity.this, R.string.save_success_msg, Toast.LENGTH_LONG).show();
                }
            });
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:nfdz,项目名称:foco,代码行数:35,代码来源:EditDocActivity.java

示例6: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case 1:
            if (getString(R.string.g6).equals(item.getTitle())) {
                item.setTitle(R.string.g7);
                this.mAdapter.setEdit(true);
                this.rippleLayout.setVisibility(8);
                this.viewOperate.setVisibility(0);
                this.viewOperate.startAnimation(AnimationUtils.loadAnimation(this, R.anim.o));
                return true;
            }
            item.setTitle(R.string.g6);
            this.mAdapter.setEdit(false);
            this.viewOperate.animate().alphaBy(1.0f).alpha(0.0f).setDuration(300).setListener
                    (new AnimatorListenerAdapter() {
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    CollectionActivity.this.viewOperate.setVisibility(8);
                    CollectionActivity.this.rippleLayout.setVisibility(0);
                    CollectionActivity.this.viewOperate.setAlpha(1.0f);
                }
            }).start();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:CollectionActivity.java

示例7: swapMenuItemTitle

import android.view.MenuItem; //导入方法依赖的package包/类
public void swapMenuItemTitle(MenuItem item) {
    if (item.getTitle() == null) {
        //IMPORTANT this prevents crashes when onOptionsItemSelected() is called from
        //the user pressing the back button or the info dialog.
        //if this is removed the other checks throw nullpointers, so keep it here.
    }
    else if(item.getTitle().toString().contains("Ascending")){
        item.setTitle(item.getTitle().toString().replace("Ascending", "Descending"));
    }
    else if (item.getTitle().toString().contains("Descending")){//the filter items will contain neither.
        item.setTitle(item.getTitle().toString().replace("Descending", "Ascending"));
    }
}
 
开发者ID:asdiamond,项目名称:CodeMineProject1,代码行数:14,代码来源:ComputerPartActivity.java

示例8: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_crime_list, menu);

    MenuItem subtitleItem = menu.findItem(R.id.show_subtitle);
    if (mSubtitleVisible) {
        subtitleItem.setTitle(R.string.hide_subtitle);
    } else {
        subtitleItem.setTitle(R.string.show_subtitle);
    }
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:13,代码来源:CrimeListFragment.java

示例9: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_crime_list, menu);

    MenuItem subtitle = menu.findItem(R.id.show_subtitle);
    if (mSubtitleVisible) {
        subtitle.setTitle(R.string.hide_subtitle);
    } else {
        subtitle.setTitle(R.string.show_subtitle);
    }
}
 
开发者ID:ivicel,项目名称:Android-Programming-BigNerd,代码行数:13,代码来源:CrimeListFragment.java

示例10: changeEditMode

import android.view.MenuItem; //导入方法依赖的package包/类
private void changeEditMode(MenuItem item) {
    if (this.tvDelete.getVisibility() == 0) {
        this.mAdapter.setShowSelect(false);
        this.tvDelete.setVisibility(8);
        this.selectLine.setVisibility(4);
        item.setTitle(getString(R.string.jk));
    } else if (this.tvDelete.getVisibility() == 8) {
        this.mAdapter.setShowSelect(true);
        this.tvDelete.setVisibility(0);
        this.selectLine.setVisibility(0);
        item.setTitle(getString(R.string.jl));
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:DownloadManageActivity.java

示例11: onPrepareOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
    logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
    logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);

    return super.onPrepareOptionsMenu(menu);
}
 
开发者ID:alexmerz,项目名称:dab-iot,代码行数:9,代码来源:MainActivity.java

示例12: onMenuItemClick

import android.view.MenuItem; //导入方法依赖的package包/类
@Override public boolean onMenuItemClick(MenuItem item) {
  if (item.getItemId() == R.id.layoutType) {
    mHorizontal = !mHorizontal;
    setupAdapter();
    item.setTitle(mHorizontal ? "Vertical" : "Horizontal");
  }
  return false;
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:9,代码来源:RecyclerViewSnapUI.java

示例13: updateDrawerUserInformation

import android.view.MenuItem; //导入方法依赖的package包/类
/**
 * Update user information in drawer
 */
private void updateDrawerUserInformation() {
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_drawer);
    Menu menu = navigationView.getMenu();
    MenuItem userName = menu.findItem(R.id.nav_user_name);
    userName.setTitle(SharedPrefClass.getFirstName(this) + " " + SharedPrefClass.getLastName(this));
    MenuItem userEmail = menu.findItem(R.id.nav_user_email);
    userEmail.setTitle(SharedPrefClass.getEmail(this));
    MenuItem userPoints = menu.findItem(R.id.nav_user_points);
    userPoints.setTitle(Integer.toString(SharedPrefClass.getPoints(this)) + " points");
}
 
开发者ID:carlosfaria94,项目名称:UbiBike-client,代码行数:14,代码来源:Friends.java

示例14: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.p, menu);
    MenuItem item = menu.findItem(R.id.action_record);
    item.setTitle("");
    item.setIcon(0);
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:WeightRecordActivity.java

示例15: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (menu != null) {
        MenuItem item = menu.findItem(R.id.action_bar_save);
        if (updateMode && item != null) {
            item.setTitle(R.string.update_hint);
        }
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:11,代码来源:NewTagFragment.java


注:本文中的android.view.MenuItem.setTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。