mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-23 07:25:25 +01:00
Added viewpager indicator library
This commit is contained in:
parent
364e9e1c5c
commit
d1b1c92efe
@ -18,7 +18,7 @@
|
||||
android:name="de.podfetcher.PodcastApp">
|
||||
<activity
|
||||
android:label="@string/app_name"
|
||||
android:name="de.podfetcher.activity.PodfetcherActivity" >
|
||||
android:name="de.podfetcher.activity.PodfetcherActivity" android:theme="@style/StyledIndicators">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -10,3 +10,4 @@
|
||||
# Project target.
|
||||
target=android-14
|
||||
android.library.reference.1=../actionbarsherlock/library/
|
||||
android.library.reference.2=../Android-ViewPagerIndicator/library
|
||||
|
@ -1,9 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main_view"
|
||||
android:id="@+id/main_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<com.viewpagerindicator.TabPageIndicator
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
|
14
res/values/styles.xml
Normal file
14
res/values/styles.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<style name="PodTheme" parent="@style/Theme.Sherlock.Light.ForceOverflow">
|
||||
<item name="vpiTabPageIndicatorStyle">@style/Widget.TabPageIndicator</item>
|
||||
</style>
|
||||
|
||||
<style name="StyledIndicators" parent="PodTheme">
|
||||
<item name="vpiTabPageIndicatorStyle">@style/Widget.TabPageIndicator</item>
|
||||
<item name="android:textColor">@color/black</item>
|
||||
</style>
|
||||
|
||||
|
||||
</resources>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user