-1

How can i display below mentioned tabs view with back button and cardview?

enter image description here

adneal
  • 30,484
  • 10
  • 122
  • 151
Mr UUUA
  • 1
  • 2

1 Answers1

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.