當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。