Created
August 4, 2017 11:57
-
-
Save thaiall/b0467ceb93699c63ca5c9ad910903921 to your computer and use it in GitHub Desktop.
Android Studio : Bottom Navigation Activity (in project: controlbutton)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thaiall.www.bottomnavigationactivity; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.design.widget.BottomNavigationView; | |
import android.support.v7.app.AppCompatActivity; | |
import android.view.MenuItem; | |
import android.widget.TextView; | |
public class MainActivity extends AppCompatActivity { | |
private TextView mTextMessage; | |
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener | |
= new BottomNavigationView.OnNavigationItemSelectedListener() { | |
@Override | |
public boolean onNavigationItemSelected(@NonNull MenuItem item) { | |
switch (item.getItemId()) { | |
case R.id.navigation_home: | |
mTextMessage.setText(R.string.title_home); | |
return true; | |
case R.id.navigation_dashboard: | |
mTextMessage.setText(R.string.title_dashboard); | |
return true; | |
case R.id.navigation_notifications: | |
mTextMessage.setText(R.string.title_notifications); | |
return true; | |
} | |
return false; | |
} | |
}; | |
@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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment