net.clcworld.thermometer.setuppager.ViewPagerAdapter.java Source code

Java tutorial

Introduction

Here is the source code for net.clcworld.thermometer.setuppager.ViewPagerAdapter.java

Source

/*
 * Copyright (C) 2014 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package net.clcworld.thermometer.setuppager;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

/**
 * Adapter class for the setup wizard view pager.
 * 
 * @author Charles L Chen (clchen@google.com)
 */
public class ViewPagerAdapter extends FragmentPagerAdapter {
    private Context mContext;

    public ViewPagerAdapter(Context context, FragmentManager fm) {
        super(fm);
        mContext = context;

    }

    @Override
    public Fragment getItem(int position) {
        Fragment f = new Fragment();
        switch (position) {
        case 0:
            f = Page00Fragment.newInstance(mContext);
            break;
        case 1:
            f = Page01Fragment.newInstance(mContext);
            break;
        case 2:
            f = Page02Fragment.newInstance(mContext);
            break;
        case 3:
            f = Page03Fragment.newInstance(mContext);
            break;
        }
        return f;
    }

    @Override
    public int getCount() {
        return 4;
    }

}