Java Code Examples for android.support.design.widget.BottomNavigationView#setOnNavigationItemSelectedListener()
The following examples show how to use
android.support.design.widget.BottomNavigationView#setOnNavigationItemSelectedListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From star-zone-android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("星座空间"); setTitleMode(TitleBar.MODE_TITLE); fManager = getSupportFragmentManager(); // setChioceItem(0); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); BottomNavigationViewHelper.disableShiftMode(navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); initView(); requestWritePermission(); }
Example 2
Source File: MainActivity.java From MBEStyle with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); StatusBarUtils.setColor(this, ContextCompat.getColor(this, R.color.colorPrimary)); BottomNavigationView bottomView = (BottomNavigationView) findViewById(R.id.bottom_bar); bottomView.setOnNavigationItemSelectedListener(this); setBottomIconOriColor(bottomView); mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); mFragments = Arrays.asList( new IconFragment(), new ApplyFragment(), new RequestFragment(), new AboutFragment()); mFragmentManager = getFragmentManager(); switchFragment(0); handleToolbarElevation(0); }
Example 3
Source File: MainActivity.java From FragmentStateManager with MIT License | 6 votes |
@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); }
Example 4
Source File: MainActivity.java From FABRevealMenu-master with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); BottomNavigationView navigation = findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(this); showXmlFragment(); }
Example 5
Source File: InFragmentActivity.java From StatusBarUtil with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.use_in_fragment); StatusBarUtil.setTransparentForWindow(this); mFragmentList = Arrays.asList( FirstFragment.newInstance(), SecondFragment.newInstance(), ThirdFragment.newInstance(), FourthFragment.newInstance() ); BottomNavigationView bottomMain = findViewById(R.id.bottom_main); bottomMain.setOnNavigationItemSelectedListener(menuItem -> { switch (menuItem.getItemId()) { case R.id.one: switchFragmentIndex(0); break; case R.id.two: switchFragmentIndex(1); break; case R.id.three: switchFragmentIndex(2); break; case R.id.four: switchFragmentIndex(3); break; default: break; } return true; }); switchFragmentIndex(0); }
Example 6
Source File: MainActivity.java From canvas with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //canvasView = findViewById(R.id.canvasView); parentView = findViewById(R.id.parentView); canvasView = new CanvasView(MainActivity.this); parentView.addView(canvasView); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); }
Example 7
Source File: BottomNavigationActivity.java From AndroidModulePattern with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bottom_navigation); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); initViewPager(); }
Example 8
Source File: BottomNavigationViewActivity.java From twoh-android-material-design with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_bottom_nav_view); bottomNavigationView = (BottomNavigationView) findViewById(R.id.btm_nav); bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()){ case R.id.action_home : Toast.makeText(BottomNavigationViewActivity.this, "Home clicked", Toast.LENGTH_SHORT).show(); break; case R.id.action_star : Toast.makeText(BottomNavigationViewActivity.this, "Star clicked", Toast.LENGTH_SHORT).show(); break; case R.id.action_money : Toast.makeText(BottomNavigationViewActivity.this, "Money clicked", Toast.LENGTH_SHORT).show(); break; } return true; } }); btTutorial = (Button) findViewById(R.id.bt_tutorial); btTutorial.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { readTheTutorial(Const.TUTORIAL_BOTTOMNAVVIEW); } }); setupToolbar(); super.onCreate(savedInstanceState); }
Example 9
Source File: BottomActivity.java From Cybernet-VPN with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bottom); mTextMessage = (TextView) findViewById(R.id.message); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); }
Example 10
Source File: NavMainActivity.java From AndroidDigIn with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_nav_main); mNavigation = (BottomNavigationView) findViewById(R.id.navigation); mNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); mVp = (ViewPager) findViewById(R.id.vp); mVp.setAdapter(new PagerAdapter(getSupportFragmentManager())); mVp.addOnPageChangeListener(new PageSelectedListener()); }
Example 11
Source File: MainActivity.java From atlas with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextMessage = (TextView) findViewById(R.id.message); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); }
Example 12
Source File: MainActivity.java From openlocate-android with MIT License | 5 votes |
private void initializeBottomNavigationView() { BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); getSupportFragmentManager().beginTransaction().replace( R.id.fragment_container, TrackFragment.getInstance() ).commit(); }
Example 13
Source File: MainActivity.java From FriendBook with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { this.overridePendingTransition(0, 0); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bottomNavigation = (BottomNavigationView) findViewById(R.id.bottom_navigation); bottomNavigation.setOnNavigationItemSelectedListener(this); getPresenter().start(); getPresenter().initContentContainer(getSupportFragmentManager(), R.id.content_view); if(savedInstanceState!=null) { savedInstanceState.getInt("selectedTabId", R.id.tab_bookcase); }else { getPresenter().dispatchTabSelectedTabId(R.id.tab_bookcase); } }
Example 14
Source File: MainActivity.java From android-kubernetes-blockchain with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); // use tech fragment - initial layout FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.frame_layout, TechFragment.newInstance()); transaction.commit(); // request queue queue = Volley.newRequestQueue(this); // check if location is permitted if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { Log.d(TAG, "access fine location not yet granted"); ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION},1); } // initialize shared preferences - persistent data sharedPreferences = this.getSharedPreferences("shared_preferences_fitcoin", Context.MODE_PRIVATE); // Check if user is already enrolled if (sharedPreferences.contains("BlockchainUserId")) { Log.d(TAG, "User already registered."); } else { // register the user registerUser(); } }
Example 15
Source File: BrowsingActivity.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 4 votes |
protected void inflateUi(@Nullable Bundle savedInstanceState) { setContentView(R.layout.activity_browsing); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerArrowDrawable drawerArrow = new DrawerArrowDrawable(this); drawerArrow.setColor(0xFFFFFF); toolbar.setNavigationIcon(drawerArrow); ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setDisplayHomeAsUpEnabled(true); supportActionBar.setDisplayShowTitleEnabled(false); } mBooksInformationDbHelper = BooksInformationDbHelper.getInstance(BrowsingActivity.this); appBarLayout = findViewById(R.id.appBar); DrawerLayout drawer = findViewById(R.id.drawer_layout); actionBarDrawerToggle = new ActionBarDrawerToggle( this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(actionBarDrawerToggle); actionBarDrawerToggle.syncState(); NavigationView navigationView = findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); toolbarDownloadOnlySwitch = findViewById(R.id.toolbar_downloaded_only_switch); navDownloadedOnlySwitch = (SwitchCompat) navigationView.getMenu().findItem(R.id.nav_item_downloaded_only).getActionView(); SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); mShouldDisplayDownloadOnly = sharedPref.getBoolean(KEY_DOWNLOADED_ONLY, false); setToolbarDownloadOnlySwitchNoCallBack(mShouldDisplayDownloadOnly); setDownloadOnlySwitchNoCallBack(mShouldDisplayDownloadOnly); toolbarDownloadOnlySwitch.setCheckedChangeListener(v -> switchDownloadOnlyFilter(!shouldDisplayDownloadedOnly())); navDownloadedOnlySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> switchDownloadOnlyFilter(isChecked)); //this is done to prevent motion of drawer when the user tries to slide thes switch navDownloadedOnlySwitch.setOnTouchListener((v, event) -> { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { v.getParent().requestDisallowInterceptTouchEvent(true); } return false; }); View filterPagerContainer = findViewById(R.id.filter_pager_container); bookListContainer = findViewById(R.id.book_list_container); View bookInfoContainer = findViewById(R.id.book_info_container); FragmentManager fragmentManager = getSupportFragmentManager(); mPaneNumber = getmumberOfpans(filterPagerContainer, bookInfoContainer); @Nullable BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation); int oldPanNumbers = savedInstanceState == null ? 0 : savedInstanceState.getInt(NUMBER_OF_PANS_KEY); browsingActivityNavigationController = BrowsingActivityNavigationController.create( mPaneNumber, oldPanNumbers, fragmentManager, savedInstanceState != null, this, bottomNavigationView, this); if (browsingActivityNavigationController != null) { browsingActivityNavigationController.intiializePans(); if (bottomNavigationView != null) { bottomNavigationView.setOnNavigationItemSelectedListener(browsingActivityNavigationController::handleButtomNavigationItem); } } appRateController = new AppRateController(this); appRateController .monitor() .showRateDialogIfMeetsConditions(this); }
Example 16
Source File: MainActivity.java From developerWorks with Apache License 2.0 | 4 votes |
/** * The ubiquitous onCreate() method, where much of the magic happens. * * @param savedInstanceState The saved bundle from a previous incarnation. We don't really * care too much about it, just based on the nature of this * particular application. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the Deque that holds notifications // Try to retrieve it from saved instance state first if (savedInstanceState != null) { Serializable savedInstanceStateSerializable = savedInstanceState.getSerializable(INSTANCE_STATE_NOTIFICATIONS); if (savedInstanceStateSerializable != null) { // This unchecked cast is okay //noinspection unchecked notifications = (ArrayDeque<NotificationContent.NotificationItem>) savedInstanceStateSerializable; } else { notifications = null; // force recreate of the Deque } } // Create the FloatingActionBar, this provides information about each fragment FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Figure out which Fragment we're looking at, and display info /// specific to that Fragment. Use the menu ID as the cracker. Toast toast; int activeFragmentId = getActiveFragmentId(); switch (getActiveFragmentId()) { // Home Fragment case R.id.navigation_home: // TODO: Toast is temporary, replace with Dialog toast = Toast.makeText(getApplicationContext(), "This (" + activeFragmentId + ") is the Home fragment", Toast.LENGTH_LONG); break; // Navigation Fragment case R.id.navigation_dashboard: // TODO: Toast is temporary, replace with Dialog toast = Toast.makeText(getApplicationContext(), "This (" + activeFragmentId + ") is the Dashboard fragment", Toast.LENGTH_LONG); break; // Notifications Fragment case R.id.navigation_notifications: // TODO: Toast is temporary, replace with Dialog toast = Toast.makeText(getApplicationContext(), "This (" + activeFragmentId + ") is the Notifications fragment", Toast.LENGTH_LONG); break; // Settings Fragment case R.id.navigation_settings: // TODO: Toast is temporary, replace with Dialog toast = Toast.makeText(getApplicationContext(), "This (" + activeFragmentId + ") is the Settings fragment", Toast.LENGTH_LONG); break; default: // TODO: Toast is temporary, replace with Dialog toast = Toast.makeText(getApplicationContext(), "Unknown Fragment ID: " + activeFragmentId + ", no info", Toast.LENGTH_LONG); } if (toast != null) { toast.show(); } } }); // Load application properties from SharedPreferences setApplicationProperties(new ApplicationProperties(getApplicationContext())); // Create the BottomNavigationView mFragmentTitle = findViewById(R.id.message); BottomNavigationView navigation = findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); // Start at home (why not?) loadHomeFragment(); // Disable the Dashboard until connected disableBottomNavigationMenuItem(R.id.navigation_dashboard); }
Example 17
Source File: MainActivity.java From easyappointments-mobile-client with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getSupportActionBar().setDisplayHomeAsUpEnabled(false); final Bundle b = getIntent().getExtras(); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { Fragment frag = null; switch (item.getItemId()) { case R.id.navigation_next_appointments: frag = getAppsFragment(); break; case R.id.navigation_customers: frag = getCustomersFragment(); break; case R.id.navigation_services: frag = getServicesFragment(); frag.setArguments(b); break; default: return false; } getSupportFragmentManager() .beginTransaction() .replace(R.id.main_content, frag) .commit(); return true; } }); appsFragment = new AppointmentFragmentList(); getSupportFragmentManager().beginTransaction().replace(R.id.main_content, getAppsFragment()).commit(); }
Example 18
Source File: HomeActivity.java From MangoBloggerAndroidApp with Mozilla Public License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); loadGTMContainer(); setContentView(R.layout.activity_home); if (savedInstanceState == null) { pendingIntroAnimation = true; } Fabric.with(this, new Crashlytics()); Firebase.setAndroidContext(this); // Obtain the FirebaseAnalytics instance. mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); mFirebaseAnalytics.setAnalyticsCollectionEnabled(true); mFirebaseAnalytics.setMinimumSessionDuration(20000); // firebase remote configuration mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); firebaseRemoteConfigSettings(); fetchFirebaseRemoteConfig(); Bundle bundle = new Bundle(); String id = "MangoBlogger"; String name = "Google analytics"; bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image"); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle); mNavigation = (BottomNavigationView) findViewById(R.id.navigation); mNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); mToolbar = (Toolbar) findViewById(R.id.toolbar); mToolbarLogo = (ImageView) findViewById(R.id.app_logo); setupToolbar(); setUpDrawer(); attachFragment(HomeFragment.newInstance(), false); }
Example 19
Source File: HomeBaseFragment.java From kute with Apache License 2.0 | 4 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); bottomNavigation = (BottomNavigationView) v.findViewById(R.id.bottomnavigation); //Initialising Broadcast receiver with its intent filter sync_friend_service_receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Returned From SyncFacebookFriendsToFirebase Service"); getFirebaseFriend(); } }; filter_sync_friend_receiver = new IntentFilter(Action); person_detail_list=new ArrayList<Person>(); friend_list=new ArrayList<String>(); /*********** Bottom Navigation Setup *******/ //set initial fragments We have loaded all the three fragments simultaneously // inorder to smooth out the transition between the three fragments FragmentTransaction frag_transaction = fm.beginTransaction(); frag_transaction.add(R.id.frameBottomBar, home_tab, "HomeTab"); frag_transaction.add(R.id.frameBottomBar, friend_tab, "FriendTab"); frag_transaction.add(R.id.frameBottomBar, my_routes_tab, "MyRoutesTab"); frag_transaction.hide(friend_tab); frag_transaction.hide(my_routes_tab); frag_transaction.commit(); bottomNavigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { //Here We are just creating a single instance of a fragment // and storing it in the Fragment backstack so that it we can invoke methods implemented through the Interfaces //For activity Communication to the fragment switch (item.getItemId()) { case R.id.hometab: showHomeTab(); break; case R.id.friendstab: showFriendTab(); break; case R.id.myroutestab: showMyRoutesTab(); break; } return true; } }); /*********** End of bottom navigation *****/ }
Example 20
Source File: MainActivity.java From GankLock with GNU General Public License v3.0 | 4 votes |
@Override protected void initView() { mContainer = findViewById(R.id.main_activity_container); BottomNavigationView navigation = findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); manager = getFragmentManager(); }