当前位置: 首页>>代码示例>>Java>>正文


Java BottomNavigationView.setOnNavigationItemSelectedListener方法代码示例

本文整理汇总了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);

}
 
开发者ID:Fr4gorSoftware,项目名称:SecScanQR,代码行数:18,代码来源:HistoryDetailsActivity.java

示例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);
}
 
开发者ID:iAcn,项目名称:MBEStyle,代码行数:26,代码来源:MainActivity.java

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

}
 
开发者ID:doljko,项目名称:youth-health,代码行数:31,代码来源:MainActivity.java

示例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();
}
 
开发者ID:pstorch,项目名称:AndroidIRCLogViewer,代码行数:18,代码来源:MainActivity.java

示例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();
}
 
开发者ID:AndroidBoySC,项目名称:Mybilibili,代码行数:33,代码来源:MainActivity.java

示例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);
}
 
开发者ID:bkhezry,项目名称:ExtraMapUtils,代码行数:10,代码来源:MainActivity.java

示例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);
    }
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:16,代码来源:MainActivity.java

示例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);
}
 
开发者ID:NaikSoftware,项目名称:ThreeDotsProgressView,代码行数:10,代码来源:MainActivity.java

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

}
 
开发者ID:Sanahm,项目名称:SudoCAM-Ku,代码行数:32,代码来源:MainActivity.java

示例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();
}
 
开发者ID:stone-payments,项目名称:Android-Uri-demo,代码行数:8,代码来源:MainActivity.java

示例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);
}
 
开发者ID:jingle1267,项目名称:AndroidRequest,代码行数:15,代码来源:MainActivity.java

示例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();
}
 
开发者ID:OpenLocate,项目名称:openlocate-android,代码行数:9,代码来源:MainActivity.java

示例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();
}
 
开发者ID:mehedi-shafi,项目名称:My-Day,代码行数:13,代码来源:MainActivity.java

示例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);
}
 
开发者ID:llvieira,项目名称:GHCli,代码行数:33,代码来源:HomePage.java

示例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();
}
 
开发者ID:alextselegidis,项目名称:easyappointments-android-client,代码行数:45,代码来源:MainActivity.java


注:本文中的android.support.design.widget.BottomNavigationView.setOnNavigationItemSelectedListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。