本文整理匯總了Java中android.support.design.widget.BottomNavigationView類的典型用法代碼示例。如果您正苦於以下問題:Java BottomNavigationView類的具體用法?Java BottomNavigationView怎麽用?Java BottomNavigationView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BottomNavigationView類屬於android.support.design.widget包,在下文中一共展示了BottomNavigationView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setBottomIconOriColor
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
private void setBottomIconOriColor(BottomNavigationView bottomView) {
try {
Field mMenuViewField = BottomNavigationView.class.getDeclaredField("mMenuView");
mMenuViewField.setAccessible(true);
BottomNavigationMenuView mMenuView = (BottomNavigationMenuView) mMenuViewField.get(bottomView);
Field mButtonsField = BottomNavigationMenuView.class.getDeclaredField("mButtons");
mButtonsField.setAccessible(true);
BottomNavigationItemView[] mButtons = (BottomNavigationItemView[]) mButtonsField.get(mMenuView);
Field mIconField = BottomNavigationItemView.class.getDeclaredField("mIcon");
mIconField.setAccessible(true);
for (BottomNavigationItemView item : mButtons) {
ImageView mIcon = (ImageView) mIconField.get(item);
mIcon.setImageTintList(null);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: 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);
}
示例3: onCreate
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
s = new Setting();
Language = s.getLang();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
Language = preferences.getString("l",Language);
setLanguage(Language);
setContentView(R.layout.activity_main);
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
fm=getSupportFragmentManager();
fm.beginTransaction().add(R.id.content,new BlankFragment()).commit();
Intent i = new Intent(this,SocketService.class);
bindService(i,myConnection,Context.BIND_AUTO_CREATE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Log.e("Brodcast","Broadcast intent onCreate invoked");
if(savedInstanceState == null){
if(!registred){
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
new IntentFilter("my-event"));
Log.e("Registre","Broadcast intent register");
registred = true;
}}
}
示例4: 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);
}
示例5: setupBottomNavigation
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
private void setupBottomNavigation() {
mBottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation);
mBottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_home:
loadHomeFragment();
return true;
case R.id.action_profile:
loadProfileFragment();
return true;
case R.id.action_settings:
loadSettingsFragment();
return true;
}
return false;
}
});
}
示例6: initialize
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
@Override
public void initialize(Bundle savedInstanceState) {
presenter.checkLogin();
BottomNavigationViewUtil.disableShiftMode(bottomNavigationView);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
selectMenu(item);
return true;
}
});
MenuItem menuItem;
if (savedInstanceState != null) {
int selectedItem = savedInstanceState.getInt("arg_selected_item", 0);
menuItem = bottomNavigationView.getMenu().findItem(selectedItem);
} else {
menuItem = bottomNavigationView.getMenu().getItem(0);
}
selectMenu(menuItem);
}
示例7: disableShiftMode
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
try {
Field shiftMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftMode.setAccessible(true);
shiftMode.setBoolean(menuView, false);
shiftMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例8: 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);
}
示例9: disableShiftMode
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
/**
* 取消BottomNavigationView各item切換時的位移動效
*
* @param navigationView 底部導航欄視圖
*/
public static void disableShiftMode(BottomNavigationView navigationView) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) navigationView.getChildAt(0);
try {
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(menuView, false);
shiftingMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
itemView.setShiftingMode(false);
itemView.setChecked(itemView.getItemData().isChecked());
}
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例10: onCreate
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message);
// Receives keyword string from Main Activity
Bundle b = getIntent().getExtras();
mKeyword = b.getString("Keyword", "");
// Initializes Bottom Navigation view and its listener
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
if (savedInstanceState == null) {
// Sends keyword string to BluetoothChatFragment
Bundle c = new Bundle();
c.putString("mKeyword", mKeyword);
fragment1.setArguments(c);
// Calls Bluetooth Chat Fragment content Views
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_content, fragment1);
transaction.commit();
}
}
示例11: onCreate
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigation);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Log.e("ddddd","dsfsfsf");
DrawerLayout 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();
((BottomNavigationView)findViewById(R.id.navigation)).setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
mActivityDelegate = new ActivityGroupDelegate(this,savedInstanceState);
mActivityGroupContainer = (ViewGroup) findViewById(R.id.content);
switchToActivity("home","com.taobao.firstbundle.FirstBundleActivity");
}
示例12: createViewInstance
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
@Override
protected RNBottomNavigation createViewInstance(final ThemedReactContext reactContext) {
final RNBottomNavigation bottomNavigation = new RNBottomNavigation(reactContext);
bottomNavigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
WritableMap event = Arguments.createMap();
event.putInt("selectedPosition", item.getOrder());
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
bottomNavigation.getId(),
"topChange",
event
);
return true;
}
});
return bottomNavigation;
}
開發者ID:timomeh,項目名稱:react-native-android-bottom-navigation,代碼行數:22,代碼來源:RNBottomNavigationManager.java
示例13: onCreate
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setSelectedItemId(R.id.navigation_marks);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
if (savedInstanceState != null) {
currentFragment = getSupportFragmentManager().getFragment(savedInstanceState, "currentFragment");
setTitle(savedInstanceState.getString("activityTitle"));
} else {
currentFragment = gradesFragment;
setTitle(R.string.grades_text);
}
int cardID = getIntent().getIntExtra("cardID", 0);
if (cardID == 1) {
currentFragment = gradesFragment;
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, currentFragment).commit();
}
示例14: onCreate
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
KakaoManager.getInstance().isForeground = true;
KakaoManager.getInstance().setContext(this);
FileManager.getInstance().init();
Logger.getInstance().init();
logLayout = findViewById(R.id.main_log);
debugLayout = findViewById(R.id.main_debug);
settingLayout = findViewById(R.id.main_setting);
initDebugLayout();
initLogLayout();
initSettingLayout();
checkPermission();
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(this);
}
示例15: onCreate
import android.support.design.widget.BottomNavigationView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reportes_navigation_drawer);
this.setTitle(R.string.nav_reportes);
/*menu*/
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_reportes);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.reportes_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 = (NavigationView) findViewById(R.id.reportes_nav_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView.setCheckedItem(R.id.nav_reportes);
}