From d1b1c92efe79e6aa7bb954d8b17ecfed2c7655b8 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Sun, 1 Jul 2012 13:41:54 +0200 Subject: [PATCH] Added viewpager indicator library --- AndroidManifest.xml | 2 +- project.properties | 1 + res/layout/main.xml | 9 +++++- res/values/styles.xml | 14 +++++++++ .../activity/PodfetcherActivity.java | 29 ++++++++++++++++--- 5 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 res/values/styles.xml diff --git a/AndroidManifest.xml b/AndroidManifest.xml index f5af6ed1d..9d296eb81 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -18,7 +18,7 @@ android:name="de.podfetcher.PodcastApp"> + android:name="de.podfetcher.activity.PodfetcherActivity" android:theme="@style/StyledIndicators"> diff --git a/project.properties b/project.properties index 62be9be8e..bdd48aa7e 100644 --- a/project.properties +++ b/project.properties @@ -10,3 +10,4 @@ # Project target. target=android-14 android.library.reference.1=../actionbarsherlock/library/ +android.library.reference.2=../Android-ViewPagerIndicator/library diff --git a/res/layout/main.xml b/res/layout/main.xml index 6c578105e..1ab614050 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -1,9 +1,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/de/podfetcher/activity/PodfetcherActivity.java b/src/de/podfetcher/activity/PodfetcherActivity.java index 3feab2c10..03df51772 100644 --- a/src/de/podfetcher/activity/PodfetcherActivity.java +++ b/src/de/podfetcher/activity/PodfetcherActivity.java @@ -23,6 +23,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; +import com.viewpagerindicator.TabPageIndicator; import de.podfetcher.R; import de.podfetcher.feed.FeedManager; @@ -39,6 +40,7 @@ public class PodfetcherActivity extends SherlockFragmentActivity { private FeedManager manager; private ViewPager viewpager; private MainPagerAdapter pagerAdapter; + private TabPageIndicator tabs; @Override public void onCreate(Bundle savedInstanceState) { @@ -46,13 +48,15 @@ public class PodfetcherActivity extends SherlockFragmentActivity { manager = FeedManager.getInstance(); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.main); - // Set up tabs ActionBar actionBar = getSupportActionBar(); - //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); - pagerAdapter = new MainPagerAdapter(getSupportFragmentManager()); + pagerAdapter = new MainPagerAdapter(getSupportFragmentManager(), this); + viewpager = (ViewPager) findViewById(R.id.viewpager); + tabs = (TabPageIndicator) findViewById(R.id.tabs); + viewpager.setAdapter(pagerAdapter); + tabs.setViewPager(viewpager); } @Override @@ -137,9 +141,12 @@ public class PodfetcherActivity extends SherlockFragmentActivity { private static final int POS_FEEDLIST = 0; private static final int POS_NEW_ITEMS = 1; private static final int POS_QUEUE = 2; + + private Context context; - public MainPagerAdapter(FragmentManager fm) { + public MainPagerAdapter(FragmentManager fm, Context context) { super(fm); + this.context = context; } @Override @@ -160,6 +167,20 @@ public class PodfetcherActivity extends SherlockFragmentActivity { public int getCount() { return NUM_ITEMS; } + + @Override + public CharSequence getPageTitle(int position) { + switch (position) { + case POS_FEEDLIST: + return context.getString(R.string.feeds_label); + case POS_NEW_ITEMS: + return context.getString(R.string.new_label); + case POS_QUEUE: + return context.getString(R.string.queue_label); + default: + return null; + } + } } }