Back to project page BBC-News-Reader.
The source code is released under:
Copyright (c) 2011, 2012, Digital Lizard (Oscar Key, Thomas Boby) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the...
If you think the Android project BBC-News-Reader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.digitallizard.bbcnewsreader; //from w w w . j a v a2 s. c om import android.content.Context; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import com.digitallizard.bbcnewsreader.data.DatabaseHandler; import com.digitallizard.bbcnewsreader.fragments.CategoryFragment; public class CategoryPagerAdapter extends FragmentStatePagerAdapter { private String[] enabledCategoryTitles; public CategoryPagerAdapter(Context context, FragmentManager fragmentManager) { super(fragmentManager); // get a list of enabled categories //FIXME should be done outside of the adapter DatabaseHandler database = new DatabaseHandler(context); enabledCategoryTitles = database.getEnabledCategories()[1]; } @Override public Fragment getItem(int position) { return CategoryFragment.newInstance(enabledCategoryTitles[position]); } @Override public int getCount() { return enabledCategoryTitles.length; } @Override public CharSequence getPageTitle(int position) { return enabledCategoryTitles[position]; } public int getPositionOfTitle(String title) { for(int i = 0; i < enabledCategoryTitles.length; i++) { if(enabledCategoryTitles[i].equals(title)) { return i; } } return -98; // should never happen } }