Swipable Linear/relative Layout
I am relatively a beginner in android. I was trying to build a similar app as the calculator shown below. The problem that I am facing is regarding deciding how to swipe the scient
Solution 1:
If you do not want to use ViewPager
, you can use ViewFlipper
.
You can use ViewPager
. You should create two fragments, for example BasicButtonsFragment
and ScientificButtonsFragment
. Then you should create a FragmentPagerAdapter
.
publicstaticclassMyAdapterextendsFragmentPagerAdapter {
publicMyAdapter(FragmentManager fm) {
super(fm);
}
@OverridepublicintgetCount() {
return2;
}
@Overridepublic Fragment getItem(int position) {
if (position == 0)
return BasicButtonsFragment.newInstace();
return ScientificButtonsFragment.newInstance();
}
}
Finnaly, set this adapter to your ViewPager
.
Solution 2:
You can you a DrawerLayout. Check it on the google. I think that is what you are looking for.
Post a Comment for "Swipable Linear/relative Layout"