当前位置: 首页>>代码示例>>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;未经允许,请勿转载。