How can i display below mentioned tabs view with back button and cardview?
Asked
Active
Viewed 38 times
1 Answers
0
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
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.
@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.

Sushant Paudel
- 96
- 14