本文整理了Java中android.support.design.widget.BottomNavigationView.setOnNavigationItemSelectedListener()
方法的一些代码示例,展示了BottomNavigationView.setOnNavigationItemSelectedListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BottomNavigationView.setOnNavigationItemSelectedListener()
方法的具体详情如下:
包路径:android.support.design.widget.BottomNavigationView
类名称:BottomNavigationView
方法名:setOnNavigationItemSelectedListener
暂无
代码示例来源:origin: ittianyu/BottomNavigationViewEx
@Override
public void setOnNavigationItemSelectedListener(OnNavigationItemSelectedListener listener) {
// if not set up with view pager, the same with father
if (null == mMyOnNavigationItemSelectedListener) {
super.setOnNavigationItemSelectedListener(listener);
return;
}
mMyOnNavigationItemSelectedListener.setOnNavigationItemSelectedListener(listener);
}
代码示例来源:origin: scwang90/SmartRefreshLayout
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index_main);
final BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(this);
ViewPager viewPager = findViewById(R.id.content);
viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
@Override
public int getCount() {
return TabFragment.values().length;
}
@Override
public Fragment getItem(int position) {
return TabFragment.values()[position].fragment();
}
});
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
@Override
public void onPageSelected(int position) {
navigation.setSelectedItemId(TabFragment.values()[position].menuId);
}
});
//状态栏透明和间距处理
StatusBarUtil.immersive(this, 0xff000000, 0.1f);
}
代码示例来源:origin: ittianyu/BottomNavigationViewEx
super.setOnNavigationItemSelectedListener(null);
return this;
super.setOnNavigationItemSelectedListener(mMyOnNavigationItemSelectedListener);
return this;
代码示例来源:origin: iMeiji/Toutiao
BottomNavigationViewHelper.disableShiftMode(bottom_navigation);
setSupportActionBar(toolbar);
bottom_navigation.setOnNavigationItemSelectedListener(item -> {
switch (item.getItemId()) {
case R.id.action_news:
代码示例来源:origin: fossasia/pslab-android
ButterKnife.bind(this);
bottomNavigationView.setOnNavigationItemSelectedListener
(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
代码示例来源:origin: githubwing/ByeBurger
mNavigationView.setOnNavigationItemSelectedListener(
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) {
代码示例来源:origin: iAcn/BiliNeat
private void setListener() {
mPager.addOnPageChangeListener(this);
mBottomBar.setOnNavigationItemSelectedListener(this);
}
代码示例来源:origin: bufferapp/AdaptableBottomNavigation
public void setupWithViewSwapper(@Nullable final ViewSwapper viewSwapper) {
if (currentViewSwapperSelectedListener != null) {
currentViewSwapperSelectedListener = null;
}
if (viewSwapper != null) {
currentViewSwapperSelectedListener = new ViewSwapperOnItemSelectedListener(viewSwapper);
super.setOnNavigationItemSelectedListener(currentViewSwapperSelectedListener);
}
}
代码示例来源:origin: wheat7/Cashew
@Override
public void setOnNavigationItemSelectedListener(@Nullable OnNavigationItemSelectedListener listener) {
// if not set up with view pager, the same with father
if (null == mMyOnNavigationItemSelectedListener) {
super.setOnNavigationItemSelectedListener(listener);
return;
}
mMyOnNavigationItemSelectedListener.setOnNavigationItemSelectedListener(listener);
}
代码示例来源:origin: TrustWallet/trust-wallet-android-source
protected void initBottomNavigation() {
navigation = findViewById(R.id.bottom_navigation);
navigation.setOnNavigationItemSelectedListener(this);
}
代码示例来源:origin: pinguo-zhouwei/AndroidTrainingSimples
private void initView() {
mBottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation_view);
//mBottomNavigationView.getMaxItemCount()
mBottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
onTabItemSelected(item.getItemId());
return true;
}
});
// 由于第一次进来没有回调onNavigationItemSelected,因此需要手动调用一下切换状态的方法
onTabItemSelected(R.id.tab_menu_home);
}
代码示例来源:origin: ddekanski/BottomNavigationViewBetweenActivities
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentViewId());
navigationView = (BottomNavigationView) findViewById(R.id.navigation);
navigationView.setOnNavigationItemSelectedListener(this);
}
代码示例来源:origin: openMF/mobile-wallet
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
ButterKnife.bind(this, rootView);
setToolbarTitle(Constants.HOME);
hideBackButton();
replaceFragment(WalletFragment.newInstance(localRepository
.getClientDetails().getClientId()), false,
R.id.bottom_navigation_fragment_container);
bottomNavigationView.setOnNavigationItemSelectedListener(
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
navigateFragment(item.getItemId(), false);
return true;
}
});
return rootView;
}
代码示例来源:origin: chenenyu/Support-25.0.0
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new AppInfoAdapter(this, getAppInfo(), R.layout.item_app_info);
mRecyclerView.setAdapter(mAdapter);
// New in recyclerview-25.0.0
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, mLayoutManager.getOrientation()));
// new in design-25.0.0
navigationView = (BottomNavigationView) findViewById(R.id.navigation);
navigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Toast.makeText(MainActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show();
return false;
}
});
}
代码示例来源:origin: aartikov/Alligator
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
initTabScreenMap();
mBottomBar.setOnNavigationItemSelectedListener(this);
mScreenSwitcher = new FragmentScreenSwitcher(SampleApplication.getNavigationFactory(), getSupportFragmentManager(), R.id.main_container);
if (savedInstanceState == null) {
mNavigator.switchTo(getTabScreen(R.id.tab_android));
}
}
代码示例来源: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: jiahuanyu/android-example-code
private void initialize() {
mBottomNavigationView = findViewById(R.id.id_layout_main_activity_bottom_navigation_view);
mFunctionFragment = new FunctionFragment();
mUIFragment = new UIFragment();
mBottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
addOrShowFragment(item.getItemId());
return true;
}
});
addOrShowFragment(R.id.id_menu_main_activity_bottom_navigation_view_function);
}
代码示例来源:origin: neXenio/BLE-Indoor-Positioning
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
// setup UI
coordinatorLayout = findViewById(R.id.coordinatorLayout);
bottomNavigationView = findViewById(R.id.bottomNavigationView);
bottomNavigationView.setOnNavigationItemSelectedListener(this);
bottomNavigationView.setSelectedItemId(R.id.navigation_radar);
// setup location
AndroidLocationProvider.initialize(this);
// setup bluetooth
BluetoothClient.initialize(this);
}
代码示例来源:origin: okaybroda/FragmentStateManager
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FrameLayout content = findViewById(R.id.content);
fragmentStateManager = new FragmentStateManager(content, getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
// A switch case should be here for showing different fragments for
// different positions which is omitted for simplicity
return new HolderFragment();
}
};
if (savedInstanceState == null) {
fragmentStateManager.changeFragment(0);
}
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
navigation.setOnNavigationItemReselectedListener(mOnNavigationItemReselectedListener);
}
代码示例来源:origin: aartikov/Alligator
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
initTabScreenMap();
mBottomBar.setOnNavigationItemSelectedListener(this);
mScreenSwitcher = new FragmentScreenSwitcher(SampleApplication.getNavigationFactory(), getSupportFragmentManager(),
R.id.main_container, new SampleScreenSwitcherAnimationProvider(getTabScreens()));
if (savedInstanceState == null) {
mNavigator.switchTo(getTabScreen(R.id.tab_android));
}
}
内容来源于网络,如有侵权,请联系作者删除!