From 7294c6bd32e362b4c0a64cadbf4dd2c191e1ad8e Mon Sep 17 00:00:00 2001 From: Marcin Zelent Date: Thu, 29 Mar 2018 23:25:18 +0200 Subject: Added observations tabs --- .../marcinzelent/liberavem/ViewPagerAdapter.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 app/src/main/java/org/marcinzelent/liberavem/ViewPagerAdapter.java (limited to 'app/src/main/java/org/marcinzelent/liberavem/ViewPagerAdapter.java') diff --git a/app/src/main/java/org/marcinzelent/liberavem/ViewPagerAdapter.java b/app/src/main/java/org/marcinzelent/liberavem/ViewPagerAdapter.java new file mode 100644 index 0000000..8c20fc9 --- /dev/null +++ b/app/src/main/java/org/marcinzelent/liberavem/ViewPagerAdapter.java @@ -0,0 +1,47 @@ +package org.marcinzelent.liberavem; + +import android.content.Context; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; + +public class ViewPagerAdapter extends FragmentPagerAdapter { + + private Context mContext; + + public ViewPagerAdapter(Context context, FragmentManager fm) { + super(fm); + mContext = context; + } + + // This determines the fragment for each tab + @Override + public Fragment getItem(int position) { + if (position == 0) { + return new MyObservationsFragment(); + } else { + return new AllObservationsFragment(); + } + } + + // This determines the number of tabs + @Override + public int getCount() { + return 2; + } + + // This determines the title for each tab + @Override + public CharSequence getPageTitle(int position) { + // Generate title based on item position + switch (position) { + case 0: + return mContext.getString(R.string.my_observations); + case 1: + return mContext.getString(R.string.all_observations); + default: + return null; + } + } + +} -- cgit v1.2.3