Android Open Source - Day Collection Pager Adapter

From Project

Back to project page


The source code is released under:

MIT License

If you think the Android project listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package eu.robertboloc.holaurv.adapters;
// www  .j  a va2 s . c o m
import android.content.Context;
import android.os.Bundle;
import android.util.SparseArray;
import eu.robertboloc.holaurv.R;
import eu.robertboloc.holaurv.fragments.DayObjectFragment;
import eu.robertboloc.holaurv.models.Day;

public class DayCollectionPagerAdapter extends FragmentStatePagerAdapter {

    public final SparseArray<String> daysOfWeek = new SparseArray<String>();

    public DayCollectionPagerAdapter(FragmentManager fm, Context ctx) {

        // Get the translations of the days of the week
        daysOfWeek.put(Day.MONDAY, ctx.getString(R.string.monday));
        daysOfWeek.put(Day.TUESDAY, ctx.getString(R.string.tuesday));
        daysOfWeek.put(Day.WEDNESDAY, ctx.getString(R.string.wednesday));
        daysOfWeek.put(Day.THURSDAY, ctx.getString(R.string.thursday));
        daysOfWeek.put(Day.FRIDAY, ctx.getString(R.string.friday));
        daysOfWeek.put(Day.SATURDAY, ctx.getString(R.string.saturday));
        daysOfWeek.put(Day.SUNDAY, ctx.getString(R.string.sunday));

    public int getCount() {
        return 7; // There are 7 days in a week (for now at least...)

    public Fragment getItem(int i) {
        Fragment fragment = new DayObjectFragment();
        Bundle args = new Bundle();
        args.putInt(DayObjectFragment.ARG_OBJECT, i);

        return fragment;

    public CharSequence getPageTitle(int position) {
        return daysOfWeek.get(position);

Java Source Code List