當前位置: 首頁>>代碼示例>>Java>>正文


Java BottomNavigationView類代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:iAcn,項目名稱:MBEStyle,代碼行數:23,代碼來源:MainActivity.java

示例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);

}
 
開發者ID:Fr4gorSoftware,項目名稱:SecScanQR,代碼行數:18,代碼來源:HistoryDetailsActivity.java

示例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;
    }}

}
 
開發者ID:RRDL,項目名稱:CRT,代碼行數:27,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:iAcn,項目名稱:MBEStyle,代碼行數:26,代碼來源:MainActivity.java

示例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;
            }
        });
    }
 
開發者ID:Learn2Crack,項目名稱:android-bottom-navigation-view,代碼行數:24,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:mgilangjanuar,項目名稱:GoSCELE,代碼行數:23,代碼來源:MainActivity.java

示例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();
    }
}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:20,代碼來源:BottomNavigationViewHelper.java

示例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);

}
 
開發者ID:doljko,項目名稱:youth-health,代碼行數:31,代碼來源:MainActivity.java

示例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();
    }
}
 
開發者ID:Implementist,項目名稱:iReading,代碼行數:25,代碼來源:CommonUtils.java

示例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();
    }
}
 
開發者ID:paulinog,項目名稱:SecretTalk,代碼行數:25,代碼來源:MessageActivity.java

示例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");
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:22,代碼來源:MainActivity.java

示例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();
}
 
開發者ID:wulkanowy,項目名稱:wulkanowy,代碼行數:27,代碼來源:DashboardActivity.java

示例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);
}
 
開發者ID:Su-Yong,項目名稱:NewKakaoBot,代碼行數:26,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:EdwardAlexis,項目名稱:Sistema-de-Comercializacion-Negocios-Jhordan,代碼行數:24,代碼來源:Reportes.java


注:本文中的android.support.design.widget.BottomNavigationView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。