Android Open Source - AndroidTrainingCode Screen Slide Page Fragment






From Project

Back to project page AndroidTrainingCode.

License

The source code is released under:

Apache License

If you think the Android project AndroidTrainingCode 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

/*
 * Copyright 2012 The Android Open Source Project
 */*from w  w w.  j a  va  2s  .c  om*/
 * 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 com.example.android.animationsdemo;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * A fragment representing a single step in a wizard. The fragment shows a dummy title indicating
 * the page number, along with some dummy text.
 *
 * <p>This class is used by the {@link CardFlipActivity} and {@link
 * ScreenSlideActivity} samples.</p>
 */
public class ScreenSlidePageFragment extends Fragment {
    /**
     * The argument key for the page number this fragment represents.
     */
    public static final String ARG_PAGE = "page";

    /**
     * The fragment's page number, which is set to the argument value for {@link #ARG_PAGE}.
     */
    private int mPageNumber;

    /**
     * Factory method for this fragment class. Constructs a new fragment for the given page number.
     */
    public static ScreenSlidePageFragment create(int pageNumber) {
        ScreenSlidePageFragment fragment = new ScreenSlidePageFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_PAGE, pageNumber);
        fragment.setArguments(args);
        return fragment;
    }

    public ScreenSlidePageFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPageNumber = getArguments().getInt(ARG_PAGE);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // Inflate the layout containing a title and body text.
        ViewGroup rootView = (ViewGroup) inflater
                .inflate(R.layout.fragment_screen_slide_page, container, false);

        // Set the title view to show the page number.
        ((TextView) rootView.findViewById(android.R.id.text1)).setText(
                getString(R.string.title_template_step, mPageNumber + 1));

        return rootView;
    }

    /**
     * Returns the page number represented by this fragment object.
     */
    public int getPageNumber() {
        return mPageNumber;
    }
}




Java Source Code List

com.example.android.animationsdemo.ApplicationTest.java
com.example.android.animationsdemo.CardFlipActivity.java
com.example.android.animationsdemo.CrossfadeActivity.java
com.example.android.animationsdemo.LayoutChangesActivity.java
com.example.android.animationsdemo.MainActivity.java
com.example.android.animationsdemo.ScreenSlideActivity.java
com.example.android.animationsdemo.ScreenSlidePageFragment.java
com.example.android.animationsdemo.TouchHighlightImageButton.java
com.example.android.animationsdemo.ZoomActivity.java
com.example.android.lifecycle.ActivityA.java
com.example.android.lifecycle.ActivityB.java
com.example.android.lifecycle.ActivityC.java
com.example.android.lifecycle.ApplicationTest.java
com.example.android.lifecycle.DialogActivity.java
com.example.android.lifecycle.util.StatusTracker.java
com.example.android.lifecycle.util.Utils.java
com.example.android.threadsample.BroadcastNotifier.java
com.example.android.threadsample.Constants.java
com.example.android.threadsample.DataProviderContract.java
com.example.android.threadsample.DataProvider.java
com.example.android.threadsample.DisplayActivity.java
com.example.android.threadsample.PhotoDecodeRunnable.java
com.example.android.threadsample.PhotoDownloadRunnable.java
com.example.android.threadsample.PhotoFragment.java
com.example.android.threadsample.PhotoManager.java
com.example.android.threadsample.PhotoTask.java
com.example.android.threadsample.PhotoThumbnailFragment.java
com.example.android.threadsample.PhotoView.java
com.example.android.threadsample.ProgressNotifier.java
com.example.android.threadsample.RSSPullParser.java
com.example.android.threadsample.RSSPullService.java