當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItem.getTitle方法代碼示例

本文整理匯總了Java中android.view.MenuItem.getTitle方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.getTitle方法的具體用法?Java MenuItem.getTitle怎麽用?Java MenuItem.getTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.MenuItem的用法示例。


在下文中一共展示了MenuItem.getTitle方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onNavigationItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
/**
 * Metodo encargado de la navegacion. Usa item.getTitle para manejar el caso de intentar
 * navegar hacia la tab en la que ya estamos
 * @param item
 * @return true si se marca la tab, false si no
 */
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    Fragment newFragment = null;
    if(!(tabActualTitle == item.getTitle())){
        tabActualTitle = item.getTitle();
        switch (item.getItemId()) {
            case R.id.action_sofa:
                newFragment = Sofa.newInstance();
                break;
            case R.id.action_torneo:
                newFragment = Torneo.newInstance();
                break;
            case R.id.action_mapas:
                newFragment = Mapas.newInstance();
                break;
        }
        FragmentTransaction transaction = context.getFragmentManager().beginTransaction();
        transaction.replace(R.id.fragment, newFragment);
        transaction.addToBackStack(null);
        transaction.commit();
        return true;
    }else{
        return false;
    }
}
 
開發者ID:cyanide4all,項目名稱:MySmashCouch,代碼行數:32,代碼來源:CustomNavigationListener.java

示例2: onLongClick

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onLongClick(View v) {
  MenuItem item = menu.findItem(v.getId());
  if (item != null && item.getTitle() != null) {
    Toast.makeText(context, item.getTitle(), Toast.LENGTH_SHORT).show();
    return true;
  }
  return false;
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:10,代碼來源:AyahToolBar.java

示例3: createFabMenuItem

import android.view.MenuItem; //導入方法依賴的package包/類
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);
    if (Utils.hasLollipop()) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:36,代碼來源:FabSpeedDial.java

示例4: markPro

import android.view.MenuItem; //導入方法依賴的package包/類
private void markPro(MenuItem menu, String sku) {
    if (sku == null || !IAB.isPurchased(sku, this)) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        boolean dark = prefs.getBoolean("dark_theme", false);
        SpannableStringBuilder ssb = new SpannableStringBuilder("  " + menu.getTitle());
        ssb.setSpan(new ImageSpan(this, dark ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        menu.setTitle(ssb);
    }
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:10,代碼來源:ActivityMain.java

示例5: markPro

import android.view.MenuItem; //導入方法依賴的package包/類
private void markPro(MenuItem menu, String sku) {
    if (sku == null || !IAB.isPurchased(sku, context)) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        boolean dark = prefs.getBoolean("dark_theme", false);
        SpannableStringBuilder ssb = new SpannableStringBuilder("  " + menu.getTitle());
        ssb.setSpan(new ImageSpan(context, dark ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        menu.setTitle(ssb);
    }
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:10,代碼來源:AdapterRule.java

示例6: 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

示例7: addActions

import android.view.MenuItem; //導入方法依賴的package包/類
/**
 * Add actions to the QuickActionView from the given menu resource id.
 *
 * @param menuId menu resource id
 * @return the QuickActionView
 */
public QuickActionView addActions(@MenuRes int menuId) {
    Menu menu = new MenuBuilder(mContext);
    new MenuInflater(mContext).inflate(menuId, menu);
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        Action action = new Action(item.getItemId(), item.getIcon(), item.getTitle());
        addAction(action);
    }
    return this;
}
 
開發者ID:ovenbits,項目名稱:QuickActionView,代碼行數:17,代碼來源:QuickActionView.java

示例8: onPrepareOptionsMenu

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (theme.isBaseLight()) {
        int black = ContextCompat.getColor(this, R.color.black);
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            SpannableString s = new SpannableString(item.getTitle());
            s.setSpan(new ForegroundColorSpan(black), 0, s.length(), 0);
            item.setTitle(s);
        }
    }
    return super.onPrepareOptionsMenu(menu);
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:14,代碼來源:ItemActivity.java

示例9: applyFontToMenuItem

import android.view.MenuItem; //導入方法依賴的package包/類
private void applyFontToMenuItem(MenuItem mi) {
    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/SourceSansPro-Semibold.otf");
    SpannableString mNewTitle = new SpannableString(mi.getTitle());
    mNewTitle.setSpan(new CustomTypefaceSpan("" , font), 0 , mNewTitle.length(),  Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    mi.setTitle(mNewTitle);
}
 
開發者ID:ahmadnurhidayat,項目名稱:Cook-It-Android-XML-Template,代碼行數:7,代碼來源:Main.java

示例10: createFabMenuItem

import android.view.MenuItem; //導入方法依賴的package包/類
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);

        if (miniFabTitleTextColorArray != null) {
            titleView.setTextColor(ContextCompat.getColorStateList(getContext(),
                    miniFabTitleTextColorArray[menuItem.getOrder()]));
        }
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);

    if (miniFabBackgroundTintArray != null) {
        miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(),
                miniFabBackgroundTintArray[menuItem.getOrder()]));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
開發者ID:Alcatraz323,項目名稱:MaterialOCR,代碼行數:47,代碼來源:FabSpeedDial.java

示例11: onOptionsItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
  CharSequence cs = item.getTitle();

  if (cs == null) {
    Log.d("DEBUG", "press actionbar back!");
    return true;
  }

  String itemTitle = item.getTitle().toString();

  Log.d("DEBUG", "item id = " + item.getItemId() + " " + itemTitle);

  if (itemTitle.equals(getString(R.string.basic_conf))) {
    Log.d("DEBUG", "tap basic setting");

    transitToFragment(basicConfigFragment);

    return true;
  } else if (itemTitle.equals(getString(R.string.spotify_conf))) {
    Log.d("DEBUG", "tap spotify setting");

    transitToFragment(spotifyConfigFragment);

    return true;
  } else if (itemTitle.equals(getString(R.string.hue_conf))) {
    Log.d("DEBUG", "tap hue setting");

    transitToFragment(hueConfigFragment);

    return true;
  } else if (itemTitle.equals(getString(R.string.remo_conf))) {
    Log.d("DEBUG", "tap remo setting");

    transitToFragment(remoConfigFragment);

    return true;
  } else if (itemTitle.contains(getString(R.string.osc_conf))) {
    Log.d("DEBUG", "tap osc setting");

    transitToFragment(oscConfigFragment);

    return true;
  } else if (itemTitle.contains(getString(R.string.midi_conf))) {
    Log.d("DEBUG", "tap midi setting");

    transitToFragment(midiConfigFragment);

    return true;
  }
  /*
   * MODIFY YOURSELF
   * Add your implemented function's configuration
   *
   */
  /*
  else if (itemTitle.equals(getString(R.string.***_config) {
    Log.d("DEBUG", "tap *** setting");

    transittToConfig(***ConfigFragment);

    return true;
  }
   */
  else if (itemTitle.equals(getString(R.string.about))) {
    Log.d("DEBUG", "tap about");

    transitToFragment(aboutFragment);

    return true;
  } else if (itemTitle.equals(getString(R.string.exit_app))) {
    finishAndRemoveTask();
  }

  return super.onOptionsItemSelected(item);
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:77,代碼來源:MainActivity.java

示例12: createAdapterItems

import android.view.MenuItem; //導入方法依賴的package包/類
private List<BottomSheetItem> createAdapterItems(int dividerBackground, int titleTextColor,
                                                 int itemTextColor, int itemBackground,
                                                 int tintColor) {
    List<BottomSheetItem> items = new ArrayList<>();
    mTitles = 0;

    boolean addedSubMenu = false;

    for (int i = 0; i < mMenu.size(); i++) {
        MenuItem item = mMenu.getItem(i);

        if (item.isVisible()) {
            if (item.hasSubMenu()) {
                SubMenu subMenu = item.getSubMenu();

                if (i != 0 && addedSubMenu) {
                    if (mMode == BottomSheetBuilder.MODE_GRID) {
                        throw new IllegalArgumentException("MODE_GRID can't have submenus." +
                                " Use MODE_LIST instead");
                    }
                    items.add(new BottomSheetDivider(dividerBackground));
                }

                CharSequence title = item.getTitle();
                if (title != null && !title.equals("")) {
                    items.add(new BottomSheetHeader(title.toString(), titleTextColor));
                    mTitles++;
                }

                for (int j = 0; j < subMenu.size(); j++) {
                    MenuItem subItem = subMenu.getItem(j);
                    if (subItem.isVisible()) {
                        items.add(new BottomSheetMenuItem(subItem,itemTextColor, itemBackground, tintColor));
                        addedSubMenu = true;
                    }
                }
            } else {
                items.add(new BottomSheetMenuItem(item, itemTextColor, itemBackground, tintColor));
            }
        }
    }
    return items;
}
 
開發者ID:yuhodev,項目名稱:login,代碼行數:44,代碼來源:BottomSheetAdapterBuilder.java

示例13: setMenuItemTextColor

import android.view.MenuItem; //導入方法依賴的package包/類
public static void setMenuItemTextColor(MenuItem menuItem, @ColorInt int textColor) {
    SpannableString s = new SpannableString(menuItem.getTitle());
    s.setSpan(new ForegroundColorSpan(textColor), 0, s.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    menuItem.setTitle(s);
}
 
開發者ID:krossovochkin,項目名稱:BottomSheetMenu,代碼行數:6,代碼來源:BottomSheetUtils.java


注:本文中的android.view.MenuItem.getTitle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。