How can i display below mentioned tabs view with back button and cardview?
First of all, if you want to use back Button on a Android phone you have to override onBackPressed() function in an Activity or a Context.
override onBackPressed()
@Override public void onBackPressed() { //TODO your code goes here! }
If you want to swipe between pages from your ViewPager you have to create a view pager and use the index of the pages to swipe between them.
index
@Override public void onBackPressed() { final ViewPager mViewPager = findViewById(R.id.viewPager); if (mViewPager.getCurrentItem() != 0) { mViewPager.setCurrentItem(0); } else { super.onBackPressed(); } }
Above mentioned code will swipe the ViewPager's page to the first page, if it is in any other page than the first one.
Copyright © 2021 Jogjafile Inc.
First of all, if you want to use back Button on a Android phone you have to
override onBackPressed()function in an Activity or a Context.If you want to swipe between pages from your ViewPager you have to create a view pager and use the
indexof the pages to swipe between them.Above mentioned code will swipe the ViewPager's page to the first page, if it is in any other page than the first one.