Basically I already have a HorizontalAdapters which means I can only swipe left and right and in those swipes I have 3 pages.
public class HorizontalViewPager extends FragmentPagerAdapter {
public HorizontalViewPager(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position){
case 0:
return ChatFragment.create();
case 1:
return EmptyFragment.create();
case 2:
return StoryFragment.create();
}
return null;
}
@Override
public int getCount() {
return 3;
}
Now I'm trying to add two more pages on top and below my EmptyFragment so when I swipe up it goes to another page and also when I swipe down.
I have my two fragments that I want to put on top and below my emptyfragment.
This is my MainActivity
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//VerticalViewPager
me.kaelaela.verticalviewpager.VerticalViewPager verticalViewPager = findViewById(R.id.am_scrollView);
VerticalViewPager scrollViewAdapter = new VerticalViewPager(getSupportFragmentManager());
verticalViewPager.setAdapter(scrollViewAdapter);
verticalViewPager.setPageTransformer(false, new DefaultTransformer());
//HorizontalViewPager
View background = findViewById(R.id.am_background_view);
ViewPager viewPager = findViewById(R.id.am_view_pager);
HorizontalViewPager adapter = new HorizontalViewPager(getSupportFragmentManager());
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(1);
And this is my EmptyFragment
public class EmptyFragment extends Fragment {
public static EmptyFragment create(){
return new EmptyFragment();
}
If you dont under stand what I'm trying to do its basically just a page that you can swipe left,right,up,and down and it views different pages.
MainLayout File
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="c.kristofer.jax2.MainActivity">
<View
android:id="@+id/am_background_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/green"/>
<me.kaelaela.verticalviewpager.VerticalViewPager
android:id="@+id/am_scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.v4.view.ViewPager
android:id="@+id/am_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
And my two layout files that I want to put above and below my emptyfragment
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
</LinearLayout>
And
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/yellow">
</LinearLayout>