java - Android: Scrolling from one Fragment to another through a ViewPager -
I have applied a ViewPager that adds several scraps together to stop the 'scrolling view' experience. As you already know, in any way I have a button on my first piece that the user has to scroll to the second piece. How do I get people to do this? Here is my code:
ViewPager XML:
& lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Layout_width = "match_parent" Android: layout_height = "match_parent" Android: orientation = "vertical" & gt; & Lt; Android.support.v4.view.ViewPager xmlns: Android = "http://schemas.android.com/apk/res/android" Android: id = "@ + id / pager" Android: layout_width = "match_parent" Android: Layout_height = "match_parent" & gt; & Lt; /android.support.v4.view.ViewPager> & Lt; / LinearLayout & gt; Slice 1:
& lt; Relative layout xmlns: android = "http://schemas.android.com/apk/res/android" Android: Layout_width = "match_parent" Android: layout_height = "match_parent" Android: background = "# 3498db" & gt; & Lt; LinearLayout Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" android: orientation = "vertical" & gt; & Lt; Android: layout_centerVertical = "true" Android: layout_gravity = "left" Android: layout_marginLeft = "15dp" Android: layout_marginTop = "25dp" android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_centerHorizontal = "true" Android: Text = "Step 1" Android: textColor = "# ffffff" android: textSize = "50dp" /> & Lt; Android: layout_center = "wrap_content" Android: layout_height = "wrap_content" android: layout_centerHorizontal = "true" android: layout_centerVertical = "true" android: layout_gravity = "center" Android: layout_marginBottom: Android: layout_width = "wrap_content" android: id = "@ + id / step1btn" Android: shadowDy = "0" Android: shadowDy = "0" Android: shadowRadius = "5" Android: Text = "Next Step" Android: background = "@ drawable / buttonshape" Android: shadowColor = "#A8A8A8" Android: shadowDx = "0" "Android: textColor =" #FFFFFF "Android: Text Size =" 30sp "/> & Lt; / LinearLayout & gt; & Lt; / RelativeLayout & gt; To reduce this post, assume that the second piece is the same XML.
Then we have two pieces here piece is Java class:
Public category RegisterPageOne spread fragment {@Override Public View onCreateView (LayoutInflater inflater, ViewGroup container, savedInstanceState bundle) {Final View V = inflater.inflate (R.layout.region_page1, container, incorrect); Button nextStep = (button) v.findViewById (R.id.step1Btn); NextStep.setOnClickListener (New OnClickListener) {@Override Public void onClick (see footage) {// where I want to call another FRAG}}); Return vi; } Public Static Register Page A New Instance (String Text) {RegisterPageOne f = new RegisterPageOne (); Bundle B = new bundle (); B.putString ("msg", text); F.setArguments (b); Return; }} Please help me :)
you do To get this, use the setCurrentItem (int item, Boolean smooth scale) method of your viewPager object. There is documentation.
Comments
Post a Comment