Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误:构造函数MainActivity.ScreenSlidePagerAdapter(FragmentManager)未定义_Java_Android_Android Viewpager - Fatal编程技术网

Java 错误:构造函数MainActivity.ScreenSlidePagerAdapter(FragmentManager)未定义

Java 错误:构造函数MainActivity.ScreenSlidePagerAdapter(FragmentManager)未定义,java,android,android-viewpager,Java,Android,Android Viewpager,我试图在中实现一个android项目,但在一个类中出现了一个错误 import android.os.Bundle; import android.annotation.SuppressLint; import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; import android.content.Intent; import android.support.v4.

我试图在中实现一个android项目,但在一个类中出现了一个错误

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

public class MainActivity extends FragmentActivity {
 private static final int NUM_PAGES = 5;
 private ViewPager mPager;
 private PagerAdapter mPagerAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When changing pages, reset the action bar actions since they are dependent
            // on which page is currently active. An alternative approach is to have each
            // fragment expose actions itself (rather than the activity exposing actions),
            // but for simplicity, the activity provides the actions in this sample.
            invalidateOptionsMenu();
        }
    });
}
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.activity_main, menu);

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

    // Add either a "next" or "finish" button to the action bar, depending on which       page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1)
                    ? R.string.action_finish
                    : R.string.action_next);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // Navigate "up" the demo structure to the launchpad activity.
            // See http://developer.android.com/design/patterns/navigation.html for more.
            NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
            return true;

        case R.id.action_previous:
            // Go to the previous step in the wizard. If there is no previous step,
            // setCurrentItem will do nothing.
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
            return true;

        case R.id.action_next:
            // Advance to the next step in the wizard. If there is no next step, setCurrentItem
            // will do nothing.
            mPager.setCurrentItem(mPager.getCurrentItem() + 1);
            return true;
    }

    return super.onOptionsItemSelected(item);
}


     private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
      public ScreenSlidePagerAdapter(FragmentManager fm) {
         super(fm);
     }

 public Fragment getItem(int position) {
        return ScreenSlidePageFragment.create(position);
    }


    public int getCount() {
        return NUM_PAGES;
    }
}
    }
我正在用安卓4.2构建这个项目

编辑:我已将代码更改为

private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
    public ScreenSlidePagerAdapter(android.support.v4.app.FragmentManager fm) {
        super(fm);
    }

然后,系统中出现了一个错误

mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());

错误:
构造函数MainActivity.ScreenSlidePagerAdapter(FragmentManager)未定义

正如我从代码中看到的那样,我发现构造函数中的
FragmentManager
类与代码中导入的
import android.app.FragmentManager
android.support.v4.app.FragmentManager
不兼容

  #For Full code

package com.team.test;

    import android.content.Intent;
    import android.content.pm.ActivityInfo;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.support.v4.app.FragmentStatePagerAdapter;
    import android.support.v4.app.NavUtils;
    import android.support.v4.view.PagerAdapter;
    import android.support.v4.view.ViewPager;
    import android.view.Menu;
    import android.view.MenuItem;

    /**
     * Demonstrates a "screen-slide" animation using a {@link ViewPager}. Because
     * {@link ViewPager} automatically plays such an animation when calling
     * {@link ViewPager#setCurrentItem(int)}, there isn't any animation-specific
     * code in this sample.
     * 
     * <p>
     * This sample shows a "next" button that advances the user to the next step in
     * a wizard, animating the current screen out (to the left) and the next screen
     * in (from the right). The reverse animation is played when the user presses
     * the "previous" button.
     * </p>
     * 
     * @see ScreenSlidePageFragment
     */
    public class MenuActivity extends FragmentActivity {
        /**
         * The number of pages (wizard steps) to show in this demo.
         */
        private static final int NUM_PAGES = 6;

        /**
         * The pager widget, which handles animation and allows swiping horizontally
         * to access previous and next wizard steps.
         */
        private ViewPager mPager;

        /**
         * The pager adapter, which provides the pages to the view pager widget.
         */
        private PagerAdapter mPagerAdapter;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            setContentView(R.layout.activity_screen_slide);

            // Instantiate a ViewPager and a PagerAdapter.
            mPager = (ViewPager) findViewById(R.id.pager);
            mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
            mPager.setAdapter(mPagerAdapter);
            mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
                @Override
                public void onPageSelected(int position) {
                    // When changing pages, reset the action bar actions since they
                    // are dependent
                    // on which page is currently active. An alternative approach is
                    // to have each
                    // fragment expose actions itself (rather than the activity
                    // exposing actions),
                    // but for simplicity, the activity provides the actions in this
                    // sample.
                    invalidateOptionsMenu();
                }
            });
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            super.onCreateOptionsMenu(menu);
            getMenuInflater().inflate(R.menu.activity_screen_slide, menu);

            menu.findItem(R.id.action_previous).setEnabled(
                    mPager.getCurrentItem() > 0);

            // Add either a "next" or "finish" button to the action bar, depending
            // on which page
            // is currently selected.
            MenuItem item = menu
                    .add(Menu.NONE,
                            R.id.action_next,
                            Menu.NONE,
                            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                                    : R.string.action_next);
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
                    | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
            return true;
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {
            case android.R.id.home:
                // Navigate "up" the demo structure to the launchpad activity.
                // See http://developer.android.com/design/patterns/navigation.html
                // for more.
                NavUtils.navigateUpTo(this, new Intent(this, Login.class));
                return true;

            case R.id.action_previous:
                // Go to the previous step in the wizard. If there is no previous
                // step,
                // setCurrentItem will do nothing.
                mPager.setCurrentItem(mPager.getCurrentItem() - 1);
                return true;

            case R.id.action_next:
                // Advance to the next step in the wizard. If there is no next step,
                // setCurrentItem
                // will do nothing.
                mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                return true;
            }

            return super.onOptionsItemSelected(item);
        }

        /**
         * A simple pager adapter that represents 5 {@link ScreenSlidePageFragment}
         * objects, in sequence.
         */
        public class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
            public ScreenSlidePagerAdapter(android.support.v4.app.FragmentManager fm) {
                super(fm);
            }

            @Override
            public android.support.v4.app.Fragment getItem(int position) {
                return ScreenSlidePageFragment.create(position);
            }

            @Override
            public int getCount() {
                return NUM_PAGES;
            }
        }
    }
只需检查您在本例中真正想要使用的
FragmentManager
类,您的问题就会得到解决。谢谢

i、 e.根据您的决定选择:

public ScreenSlidePagerAdapter(android.app.FragmentManager fm) {
        super(fm);
    }

并使用适当的类在您的
main活动中导入。

而不是此:

mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());
这样做:

mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
因为

getFragmentManager()
与导入android.app.FragmentManager一起使用

getSupportFragmentManager()
android.support.v4.app.FragmentManager

一起提供完整代码
  #For Full code

package com.team.test;

    import android.content.Intent;
    import android.content.pm.ActivityInfo;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.support.v4.app.FragmentStatePagerAdapter;
    import android.support.v4.app.NavUtils;
    import android.support.v4.view.PagerAdapter;
    import android.support.v4.view.ViewPager;
    import android.view.Menu;
    import android.view.MenuItem;

    /**
     * Demonstrates a "screen-slide" animation using a {@link ViewPager}. Because
     * {@link ViewPager} automatically plays such an animation when calling
     * {@link ViewPager#setCurrentItem(int)}, there isn't any animation-specific
     * code in this sample.
     * 
     * <p>
     * This sample shows a "next" button that advances the user to the next step in
     * a wizard, animating the current screen out (to the left) and the next screen
     * in (from the right). The reverse animation is played when the user presses
     * the "previous" button.
     * </p>
     * 
     * @see ScreenSlidePageFragment
     */
    public class MenuActivity extends FragmentActivity {
        /**
         * The number of pages (wizard steps) to show in this demo.
         */
        private static final int NUM_PAGES = 6;

        /**
         * The pager widget, which handles animation and allows swiping horizontally
         * to access previous and next wizard steps.
         */
        private ViewPager mPager;

        /**
         * The pager adapter, which provides the pages to the view pager widget.
         */
        private PagerAdapter mPagerAdapter;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            setContentView(R.layout.activity_screen_slide);

            // Instantiate a ViewPager and a PagerAdapter.
            mPager = (ViewPager) findViewById(R.id.pager);
            mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
            mPager.setAdapter(mPagerAdapter);
            mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
                @Override
                public void onPageSelected(int position) {
                    // When changing pages, reset the action bar actions since they
                    // are dependent
                    // on which page is currently active. An alternative approach is
                    // to have each
                    // fragment expose actions itself (rather than the activity
                    // exposing actions),
                    // but for simplicity, the activity provides the actions in this
                    // sample.
                    invalidateOptionsMenu();
                }
            });
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            super.onCreateOptionsMenu(menu);
            getMenuInflater().inflate(R.menu.activity_screen_slide, menu);

            menu.findItem(R.id.action_previous).setEnabled(
                    mPager.getCurrentItem() > 0);

            // Add either a "next" or "finish" button to the action bar, depending
            // on which page
            // is currently selected.
            MenuItem item = menu
                    .add(Menu.NONE,
                            R.id.action_next,
                            Menu.NONE,
                            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                                    : R.string.action_next);
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
                    | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
            return true;
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {
            case android.R.id.home:
                // Navigate "up" the demo structure to the launchpad activity.
                // See http://developer.android.com/design/patterns/navigation.html
                // for more.
                NavUtils.navigateUpTo(this, new Intent(this, Login.class));
                return true;

            case R.id.action_previous:
                // Go to the previous step in the wizard. If there is no previous
                // step,
                // setCurrentItem will do nothing.
                mPager.setCurrentItem(mPager.getCurrentItem() - 1);
                return true;

            case R.id.action_next:
                // Advance to the next step in the wizard. If there is no next step,
                // setCurrentItem
                // will do nothing.
                mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                return true;
            }

            return super.onOptionsItemSelected(item);
        }

        /**
         * A simple pager adapter that represents 5 {@link ScreenSlidePageFragment}
         * objects, in sequence.
         */
        public class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
            public ScreenSlidePagerAdapter(android.support.v4.app.FragmentManager fm) {
                super(fm);
            }

            @Override
            public android.support.v4.app.Fragment getItem(int position) {
                return ScreenSlidePageFragment.create(position);
            }

            @Override
            public int getCount() {
                return NUM_PAGES;
            }
        }
    }
包com.team.test; 导入android.content.Intent; 导入android.content.pm.ActivityInfo; 导入android.os.Bundle; 导入android.support.v4.app.FragmentActivity; 导入android.support.v4.app.FragmentStatePagerAdapter; 导入android.support.v4.app.NavUtils; 导入android.support.v4.view.PagerAdapter; 导入android.support.v4.view.ViewPager; 导入android.view.Menu; 导入android.view.MenuItem; /** *使用{@link ViewPager}演示“屏幕幻灯片”动画。因为 *{@link ViewPager}在调用时自动播放这样的动画 *{@link ViewPager#setCurrentItem(int)},没有任何特定于动画的内容 *此示例中的代码。 * * *此示例显示一个“下一步”按钮,该按钮将用户推进到中的下一步 *向导,设置当前屏幕(左侧)和下一屏幕的动画 *(从右边)进来。当用户按下时,将播放反向动画 *“上一步”按钮。 *

* *@参见ScreenSlidePageFragment */ 公共类菜单活动扩展了碎片活动{ /** *要在此演示中显示的页数(向导步骤)。 */ 私有静态最终int NUM_PAGES=6; /** *寻呼机小部件,处理动画并允许水平滑动 *访问上一个和下一个向导步骤。 */ 私人寻呼机; /** *寻呼机适配器,为查看寻呼机小部件提供页面。 */ 私人寻呼器; @凌驾 创建时受保护的void(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN\u ORIENTATION\u Picture); setContentView(R.layout.activity\u screen\u slide); //实例化ViewPager和PagerAdapter。 mPager=(ViewPager)findViewById(R.id.pager); mPagerAdapter=新屏幕幻灯片页面适配器(getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter); mPager.setOnPageChangeListener(新的ViewPager.SimpleOnPageChangeListener(){ @凌驾 已选择页面上的公共无效(内部位置){ //更改页面时,请重置操作栏操作,因为它们 //依赖 //当前处于活动状态的页面。另一种方法是 //各有各的 //片段公开动作本身(而不是活动 //揭露行动), //但为了简单起见,活动提供了以下操作: //样品。 无效操作菜单(); } }); } @凌驾 公共布尔onCreateOptions菜单(菜单){ super.onCreateOptions菜单(菜单); getMenuInflater().充气(R.菜单.活动\屏幕\幻灯片,菜单); menu.findItem(R.id.action\u previous).setEnabled( mPager.getCurrentItem()>0); //根据需要,在操作栏中添加“下一步”或“完成”按钮 //在哪一页 //当前已选定。 菜单项=菜单 。添加(菜单。无, R.id.action_下一步, 菜单。无, (mPager.getCurrentItem()==mPagerAdapter.getCount()-1)?R.string.action\u完成 :R.string.action\u next); item.setShowAsAction(MenuItem.SHOW\u AS\u ACTION\u IF\u房间 |菜单项。显示为带有文本的操作); 返回true; } @凌驾 公共布尔值onOptionsItemSelected(菜单项项){ 开关(item.getItemId()){ 案例android.R.id.home: //将演示结构“向上”导航到launchpad活动。 //看http://developer.android.com/design/patterns/navigation.html //更多。 NavUtils.navigateUpTo(this,newintent(this,Login.class)); 返回true; 案例R.id.action_先前: //转到向导中的上一步。如果没有上一步 //步骤,, //setCurrentItem将不执行任何操作。 mPager.setCurrentItem(mPager.getCurrentItem()-1); 返回true; 案例R.id.行动\下一步: //前进到向导中的下一步。如果没有下一步, //塞特库尔
  #For Full code

package com.team.test;

    import android.content.Intent;
    import android.content.pm.ActivityInfo;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.support.v4.app.FragmentStatePagerAdapter;
    import android.support.v4.app.NavUtils;
    import android.support.v4.view.PagerAdapter;
    import android.support.v4.view.ViewPager;
    import android.view.Menu;
    import android.view.MenuItem;

    /**
     * Demonstrates a "screen-slide" animation using a {@link ViewPager}. Because
     * {@link ViewPager} automatically plays such an animation when calling
     * {@link ViewPager#setCurrentItem(int)}, there isn't any animation-specific
     * code in this sample.
     * 
     * <p>
     * This sample shows a "next" button that advances the user to the next step in
     * a wizard, animating the current screen out (to the left) and the next screen
     * in (from the right). The reverse animation is played when the user presses
     * the "previous" button.
     * </p>
     * 
     * @see ScreenSlidePageFragment
     */
    public class MenuActivity extends FragmentActivity {
        /**
         * The number of pages (wizard steps) to show in this demo.
         */
        private static final int NUM_PAGES = 6;

        /**
         * The pager widget, which handles animation and allows swiping horizontally
         * to access previous and next wizard steps.
         */
        private ViewPager mPager;

        /**
         * The pager adapter, which provides the pages to the view pager widget.
         */
        private PagerAdapter mPagerAdapter;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            setContentView(R.layout.activity_screen_slide);

            // Instantiate a ViewPager and a PagerAdapter.
            mPager = (ViewPager) findViewById(R.id.pager);
            mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
            mPager.setAdapter(mPagerAdapter);
            mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
                @Override
                public void onPageSelected(int position) {
                    // When changing pages, reset the action bar actions since they
                    // are dependent
                    // on which page is currently active. An alternative approach is
                    // to have each
                    // fragment expose actions itself (rather than the activity
                    // exposing actions),
                    // but for simplicity, the activity provides the actions in this
                    // sample.
                    invalidateOptionsMenu();
                }
            });
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            super.onCreateOptionsMenu(menu);
            getMenuInflater().inflate(R.menu.activity_screen_slide, menu);

            menu.findItem(R.id.action_previous).setEnabled(
                    mPager.getCurrentItem() > 0);

            // Add either a "next" or "finish" button to the action bar, depending
            // on which page
            // is currently selected.
            MenuItem item = menu
                    .add(Menu.NONE,
                            R.id.action_next,
                            Menu.NONE,
                            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                                    : R.string.action_next);
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
                    | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
            return true;
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {
            case android.R.id.home:
                // Navigate "up" the demo structure to the launchpad activity.
                // See http://developer.android.com/design/patterns/navigation.html
                // for more.
                NavUtils.navigateUpTo(this, new Intent(this, Login.class));
                return true;

            case R.id.action_previous:
                // Go to the previous step in the wizard. If there is no previous
                // step,
                // setCurrentItem will do nothing.
                mPager.setCurrentItem(mPager.getCurrentItem() - 1);
                return true;

            case R.id.action_next:
                // Advance to the next step in the wizard. If there is no next step,
                // setCurrentItem
                // will do nothing.
                mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                return true;
            }

            return super.onOptionsItemSelected(item);
        }

        /**
         * A simple pager adapter that represents 5 {@link ScreenSlidePageFragment}
         * objects, in sequence.
         */
        public class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
            public ScreenSlidePagerAdapter(android.support.v4.app.FragmentManager fm) {
                super(fm);
            }

            @Override
            public android.support.v4.app.Fragment getItem(int position) {
                return ScreenSlidePageFragment.create(position);
            }

            @Override
            public int getCount() {
                return NUM_PAGES;
            }
        }
    }
private static final int NUM_PAGES = 5;

private ViewPager mPager;


private PagerAdapter mPagerAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_screen_slide);

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.pager);
    mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {

            invalidateOptionsMenu();
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.activity_screen_slide, menu);

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);


    MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1)
                    ? R.string.action_finish
                    : R.string.action_next);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:

            NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
            return true;

        case R.id.action_previous:

            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
            return true;

        case R.id.action_next:

            mPager.setCurrentItem(mPager.getCurrentItem() + 1);
            return true;
    }

    return super.onOptionsItemSelected(item);
}


private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
    public ScreenSlidePagerAdapter(android.support.v4.app.FragmentManager fm) {
        super(fm);
    }

    @Override
    public android.support.v4.app.Fragment getItem(int position) {
        return ScreenSlidePageFragment.create(position);
    }

    @Override
    public int getCount() {
        return NUM_PAGES;
    }
}}
public static final String ARG_PAGE = "page";


private int mPageNumber;


public static android.support.v4.app.Fragment create(int pageNumber) {
    android.support.v4.app.Fragment fragment = new android.support.v4.app.Fragment();
    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) {

    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;
}



public int getPageNumber() {
    return mPageNumber;
}}