本文整理了Java中android.support.design.widget.BottomNavigationView.getMenu()
方法的一些代码示例,展示了BottomNavigationView.getMenu()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BottomNavigationView.getMenu()
方法的具体详情如下:
包路径:android.support.design.widget.BottomNavigationView
类名称:BottomNavigationView
方法名:getMenu
暂无
代码示例来源:origin: willowtreeapps/Hyperion-Android
@NonNull
@Override
public List<ViewAttribute> collect(BottomNavigationView view, AttributeTranslator attributeTranslator) {
final Context context = view.getContext();
final Resources res = context.getResources();
List<ViewAttribute> attributes = new ArrayList<>();
attributes.add(new ViewAttribute<>("MaxItemCount", view.getMaxItemCount()));
attributes.add(Collectors.createColorAttribute(view, "ItemTint", view.getItemIconTintList()));
attributes.add(Collectors.createColorAttribute(view, "ItemTextColor", view.getItemTextColor()));
attributes.add(new ViewAttribute<>("SelectedItemId", new ResourceValue(res, view.getSelectedItemId())));
attributes.add(new ViewAttribute<>("ItemBackgroundRes", new ResourceValue(res, view.getItemBackgroundResource())));
attributes.addAll(Collectors.createMenuAttributes(context, view.getMenu()));
return attributes;
}
}
代码示例来源:origin: ddekanski/BottomNavigationViewBetweenActivities
void selectBottomNavigationBarItem(int itemId) {
MenuItem item = navigationView.getMenu().findItem(itemId);
item.setChecked(true);
}
代码示例来源:origin: brucevanfdm/BottomNavigationView
@Override
public void onPageSelected(int position) {
if (menuItem != null) {
menuItem.setChecked(false);
} else {
bottomNavigationView.getMenu().getItem(0).setChecked(false);
}
menuItem = bottomNavigationView.getMenu().getItem(position);
menuItem.setChecked(true);
}
代码示例来源:origin: InnoFang/Android-Code-Demos
@Override
public void onPageSelected(int position) {
if (null != mMenuItem) {
mMenuItem.setChecked(false);
} else {
mBottomNavigationView.getMenu().getItem(0).setChecked(false);
}
mMenuItem = mBottomNavigationView.getMenu().getItem(position);
mMenuItem.setChecked(true);
}
代码示例来源:origin: aartikov/Alligator
@Override
public void onScreenSwitched(@Nullable Screen screenFrom, Screen screenTo) {
int tabId = getTabId(screenTo);
mBottomBar.getMenu().findItem(tabId).setChecked(true);
}
代码示例来源:origin: AbrahamCaiJin/BottomAndShapeDemo
@Override
public void onPageSelected(int position) {
bottomNavigationView.getMenu().getItem(position).setChecked(true);
}
代码示例来源:origin: LonamiWebs/Stringlate
@Override
public void onPageSelected(final int position) {
mBottomNavigationView.getMenu().getItem(position).setChecked(true);
}
代码示例来源:origin: jaisonfdo/BottomNavigation
@Override
public void onPageSelected(int position) {
if (prevMenuItem != null) {
prevMenuItem.setChecked(false);
}
else
{
bottomNavigationView.getMenu().getItem(0).setChecked(false);
}
Log.d("page", "onPageSelected: "+position);
bottomNavigationView.getMenu().getItem(position).setChecked(true);
prevMenuItem = bottomNavigationView.getMenu().getItem(position);
}
代码示例来源:origin: aartikov/Alligator
@Override
public void onScreenSwitched(@Nullable Screen screenFrom, Screen screenTo) {
int tabId = getTabId(screenTo);
mBottomBar.getMenu().findItem(tabId).setChecked(true);
bindNavigationContext(); // rebind NavigationContext because we need to set another container id and another child fragment manager.
}
代码示例来源:origin: JBossOutreach/lead-management-android
private void selectInitialNavigationItem() {
final @IdRes int initialItem = R.id.nav_contacts;
onNavigationItemSelected(navigationView.getMenu().findItem(initialItem));
navigationView.setSelectedItemId(initialItem);
}
代码示例来源:origin: segunfamisa/bottom-navigation-demo
@Override
public void onBackPressed() {
MenuItem homeItem = mBottomNav.getMenu().getItem(0);
if (mSelectedItem != homeItem.getItemId()) {
// select home item
selectFragment(homeItem);
} else {
super.onBackPressed();
}
}
代码示例来源:origin: jbruchanov/AnUitor
@Override
protected HashMap<String, Object> fillValues(View v, HashMap<String, Object> data, HashMap<String, Object> parentData) {
super.fillValues(v, data, parentData);
BottomNavigationView view = (BottomNavigationView) v;
data.put("ItemBackgroundResource", IdsHelper.getNameForId(view.getItemBackgroundResource()));
data.put("ItemIconTintList", String.valueOf(view.getItemIconTintList()));
data.put("ItemTextColor", String.valueOf(view.getItemTextColor()));
data.put("MaxItemCount", view.getMaxItemCount());
data.put("Menu:", view.getMenu());
return data;
}
}
代码示例来源:origin: segunfamisa/bottom-navigation-demo
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBottomNav = (BottomNavigationView) findViewById(R.id.navigation);
mBottomNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
selectFragment(item);
return true;
}
});
MenuItem selectedItem;
if (savedInstanceState != null) {
mSelectedItem = savedInstanceState.getInt(SELECTED_ITEM, 0);
selectedItem = mBottomNav.getMenu().findItem(mSelectedItem);
} else {
selectedItem = mBottomNav.getMenu().getItem(0);
}
selectFragment(selectedItem);
}
代码示例来源:origin: JustinRoom/JSCKit
private void initViewPager() {
MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
noScrollViewPager.setAdapter(adapter);
List<Fragment> fragments = new ArrayList<>(dotViews.length);
for (int i = 0; i < dotViews.length; i++) {
Bundle bundle = new Bundle();
bundle.putString("content", navigation.getMenu().findItem(MENU_ID[i]).getTitle().toString());
DefaultFragment fragment = new DefaultFragment();
fragment.setArguments(bundle);
fragments.add(fragment);
}
adapter.setFragments(fragments);
}
代码示例来源:origin: hamidness/restring
bottomNavigationView.getMenu().findItem(entry.getKey()).setTitle(
resources.getString(entry.getValue().title)
);
bottomNavigationView.getMenu().findItem(entry.getKey()).setTitleCondensed(
resources.getString(entry.getValue().titleCondensed)
);
代码示例来源:origin: TrustWallet/trust-wallet-android-source
protected void setBottomMenu(@MenuRes int menuRes) {
navigation.getMenu().clear();
navigation.inflateMenu(menuRes);
}
代码示例来源:origin: segunfamisa/bottom-navigation-demo
for (int i = 0; i< mBottomNav.getMenu().size(); i++) {
MenuItem menuItem = mBottomNav.getMenu().getItem(i);
menuItem.setChecked(menuItem.getItemId() == item.getItemId());
代码示例来源:origin: hamidness/restring
} else if (view instanceof BottomNavigationView) {
BottomNavigationView bottomNavigationView = (BottomNavigationView) view;
int itemCount = bottomNavigationView.getMenu().size();
for (int item = 0; item < itemCount; item++) {
assertThat("BottomNavigationView#" + item + "[title]",
bottomNavigationView.getMenu().getItem(item).getTitle().toString(), startsWith(getLanguage()));
assertThat("BottomNavigationView#" + item + "[titleCondensed]",
bottomNavigationView.getMenu().getItem(item).getTitleCondensed().toString(), startsWith(getLanguage()));
代码示例来源:origin: Lauzy/LBehavior
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_demo_fragment_activity);
mFrameLayout = findViewById(R.id.frame_main);
mFloatingActionButton = findViewById(R.id.fab_mode);
mToolbar = findViewById(R.id.toolbar_common);
mBottomMainNavigation = findViewById(R.id.bottom_main_navigation);
loadFragment(savedInstanceState);
mToolBarBehavior = CommonBehavior.from(mToolbar);
mBottomBehavior = CommonBehavior.from(mBottomMainNavigation);
MenuItem item = mBottomMainNavigation.getMenu().getItem(0);
onNavigationItemSelected(item);//默认选中第一个
mBottomMainNavigation.setOnNavigationItemSelectedListener(this);
mToolBarBehavior.setMinScrollY(50);
mToolBarBehavior.setScrollYDistance(100);
mToolBarBehavior.setDuration(1000);
mToolBarBehavior.setInterpolator(new BounceInterpolator());
mBottomBehavior.setMinScrollY(20);
mBottomBehavior.setScrollYDistance(100);
mBottomBehavior.setDuration(1000);
mBottomBehavior.setInterpolator(new BounceInterpolator());
CommonBehavior floatActionBehavior = CommonBehavior.from(mFloatingActionButton);
floatActionBehavior.setMinScrollY(20);
floatActionBehavior.setScrollYDistance(100);
floatActionBehavior.setDuration(1000);
floatActionBehavior.setInterpolator(new BounceInterpolator());
}
内容来源于网络,如有侵权,请联系作者删除!