1
私は3つのタブを持ち、ホームタブには、特定のアイテムをクリックすると、意図を使ってタブ3に移動したいが、動作しないナビゲーションドロワーがあります。 私のコードは次のとおりです。あなたがいない活動のフラグメントを切り替えているクリックしてタブを切り替える方法
//Initializing the tablayout
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
//Adding the tabs using addTab() method
tabLayout.addTab(tabLayout.newTab().setText("Home"));
tabLayout.addTab(tabLayout.newTab().setText("Read"));
tabLayout.addTab(tabLayout.newTab().setText("Me"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
//Initializing viewPager
viewPager = (ViewPager) findViewById(R.id.pager);
// viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
//Creating our pager adapter
Pager adapter = new Pager(getSupportFragmentManager(), tabLayout.getTabCount());
//Adding adapter to pager
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
//Adding onTabSelectedListener to swipe views
tabLayout.setOnTabSelectedListener(tabLayout.this);
//// drawable navbar
mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView); // Assigning the RecyclerView Object to the xml View
mRecyclerView.setHasFixedSize(true); // Letting the system know that the list objects are of fixed size
mAdapter = new MyAdapter(TITLES,ICONS,NAME,EMAIL,PROFILE); // Creating the Adapter of MyAdapter class(which we are going to see in a bit)
// And passing the titles,icons,header view name, header view email,
// and header view profile picture
mRecyclerView.setAdapter(mAdapter); //
mLayoutManager = new LinearLayoutManager(this); //
mRecyclerView.setLayoutManager(mLayoutManager); //
mRecyclerView.addOnItemTouchListener(
new RecyclerItemClickListener(tabLayout.this, new
RecyclerItemClickListener.OnItemClickListener() {
@Override public void onItemClick(View view, int position) {
switch(position){
case 1:
Intent go=new Intent(tabLayout.this,Tab1.class);
startActivity(go);
break;`
タブすなわちホーム、読む、私が活動またはフラグメントはありますか? –
これは断片です –