當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。