当前位置: 首页>>代码示例>>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;未经允许,请勿转载。