本文整理匯總了Java中android.support.design.widget.BottomNavigationView.setOnNavigationItemSelectedListener方法的典型用法代碼示例。如果您正苦於以下問題:Java BottomNavigationView.setOnNavigationItemSelectedListener方法的具體用法?Java BottomNavigationView.setOnNavigationItemSelectedListener怎麽用?Java BottomNavigationView.setOnNavigationItemSelectedListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.design.widget.BottomNavigationView
的用法示例。
在下文中一共展示了BottomNavigationView.setOnNavigationItemSelectedListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history_details);
tvCode = (TextView) findViewById(R.id.tvCodeHD);
action_navigation = (BottomNavigationView) findViewById(R.id.history_action_navigation);
BottomNavigationViewHelper.disableShiftMode(action_navigation);
action_navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
historyDatabaseHelper = new DatabaseHelper(this);
//Get the extra information from the history listview. and set the text in the textview eqaul to code
Intent receivedIntent = getIntent();
selectedID = receivedIntent.getIntExtra("id", -1); //-1 is the default value
selectedCode = receivedIntent.getStringExtra("code");
tvCode.setText(selectedCode);
}
示例2: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@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);
}
示例3: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.content, ProjectFragment.newInstance()); // newInstance() is a static factory method.
transaction.commit();
shakeSensor = new ShakeSensor();
shakeSensor.setListener(this);
shakeSensor.init(this);
}
示例4: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextMessage = (TextView) findViewById(R.id.message);
mTextMessage.setLinksClickable(true);
mTextMessage.setMovementMethod(LinkMovementMethod.getInstance());
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
baseUrl = preferences.getString("base_url", null);
nickname = preferences.getString("nickname", null);
loadLog();
}
示例5: initView
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
private void initView() {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
//這裏注意設置標題要在setsupportactionbar方法前調用才會有效
mToolbar.setTitle(" ");
setSupportActionBar(mToolbar);
mToolbar.setNavigationIcon(R.mipmap.home3);
mToolbar.setLogo(R.mipmap.toolicon2);
mToolbar.setOnMenuItemClickListener(mOnMenuItemClickListener);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mNavigationView = (NavigationView) findViewById(R.id.nav_view);
//以下兩行代碼是如何獲取navigationView中子view的方式
View headerView = mNavigationView.getHeaderView(0);
textViewLogin = (TextView) headerView.findViewById(R.id.tv_login);
textViewShare = (TextView) findViewById(R.id.share_main);
//mViewPager = (ViewPager) findViewById(R.id.vp_main);
mTabLayout = (TabLayout) findViewById(R.id.tab_main);
bottom_main_navigation = (BottomNavigationView) findViewById(R.id.bottom_main_navigation);
//該方法調用helper類去掉大於3時的動畫
BottomNavigationViewHelper.disableShiftMode(bottom_main_navigation);
MenuItem item = bottom_main_navigation.getMenu().getItem(0);
bottom_main_navigation.setOnNavigationItemSelectedListener(this);
onNavigationItemSelected(item);//默認選中第一個
mCircleImageView = (CircleImageView) headerView.findViewById(R.id.icon_image);
mFilter = new IntentFilter();
mFilter.addAction("com.songchao.mybilibili.notifilogin");
mFilter.addAction("com.songchao.mybilibili.notifiout");
mNotifyLoginUIReceiver = new NotifyLoginUIReceiver();
registerReceiver(mNotifyLoginUIReceiver,mFilter);
//應該把SharedPreferences封裝為一個工具類,這樣會減少很多重複代碼
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mEditor = mPreferences.edit();
}
示例6: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
navigation = (BottomNavigationView) findViewById(R.id.navigation);
fragmentNavigator = new FragmentNavigator(getSupportFragmentManager(), new FragmentAdapter(), R.id.contentFrameLayout);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
fragmentNavigator.showFragment(0);
}
示例7: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@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);
}
}
示例8: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@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);
}
示例9: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.app_bar_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(R.string.app_name);
text = (TextView) findViewById(R.id.git);
text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Sanahm/")));
}
});
BottomNavigationView navigationView = (BottomNavigationView) findViewById(R.id.nav_view);
navigationView.setOnNavigationItemSelectedListener(this);
/*imgView = (ImageView) findViewById(R.id.img_trans);
Drawable [] drawable = new Drawable[] { getResources().getDrawable(R.drawable.pn1), getResources().getDrawable(R.drawable.pn2),getResources().getDrawable(R.drawable.pn3)};
TransitionDrawableExt drawableExt = new TransitionDrawableExt(drawable);
imgView.setBackground(drawableExt);*/
//((TransitionDrawable) imgView.getDrawable()).startTransition(3000);
}
示例10: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(this);
fragmentManager.beginTransaction().add(R.id.fragment_container, fragment).commit();
}
示例11: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RequestAgent.showLog();
RequestAgent.init(getApplicationContext(), "https://api.github.com/");
mTextMessage = (TextView) findViewById(R.id.message);
mRequest = (TextView) findViewById(R.id.tv_request);
mResponse = (TextView) findViewById(R.id.tv_response);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
}
示例12: initializeBottomNavigationView
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
private void initializeBottomNavigationView() {
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
getSupportFragmentManager().beginTransaction().replace(
R.id.fragment_container,
TrackFragment.getInstance()
).commit();
}
示例13: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
fragmentManager = getSupportFragmentManager();
transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.container, new HomeFragment()).commit();
}
示例14: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build();
StrictMode.setThreadPolicy(policy);
setContentView(R.layout.activity_home_page);
Toolbar toolbar = findViewById(R.id.toolbar);
navBar = (BottomNavigationView) findViewById(R.id.navigation);
navBar.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
selectFragment(item);
return true;
}
});
// get user from login page
Intent intent = getIntent();
this.user = intent.getParcelableExtra(KEY_USER);
Log.d("TOKEN", Authentication.getToken(getApplicationContext()));
MenuItem selectedItem;
if (savedInstanceState != null) {
mSelectedItem = savedInstanceState.getInt(SELECTED_ITEM, 0);
selectedItem = navBar.getMenu().findItem(mSelectedItem);
} else {
selectedItem = navBar.getMenu().getItem(2);
}
selectFragment(selectedItem);
}
示例15: onCreate
import android.support.design.widget.BottomNavigationView; //導入方法依賴的package包/類
@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();
}