diff options
7 files changed, 54 insertions, 38 deletions
diff --git a/samples/Support13Demos/res/layout/fragment_pager.xml b/samples/Support13Demos/res/layout/fragment_pager.xml index 2268c8902..cc07d84df 100644 --- a/samples/Support13Demos/res/layout/fragment_pager.xml +++ b/samples/Support13Demos/res/layout/fragment_pager.xml @@ -28,10 +28,17 @@ android:layout_weight="1"> </android.support.v13.view.ViewPager> - <Button android:id="@+id/new_fragment" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_weight="0" - android:text="@string/new_fragment"> - <requestFocus /> - </Button> + <LinearLayout android:orientation="horizontal" + android:gravity="center" android:measureWithLargestChild="true" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="0"> + <Button android:id="@+id/goto_first" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="@string/first"> + </Button> + <Button android:id="@+id/goto_last" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="@string/last"> + </Button> + </LinearLayout> </LinearLayout> diff --git a/samples/Support13Demos/res/values/strings.xml b/samples/Support13Demos/res/values/strings.xml index af6ec4a75..818597c58 100644 --- a/samples/Support13Demos/res/values/strings.xml +++ b/samples/Support13Demos/res/values/strings.xml @@ -23,9 +23,9 @@ siwuf cakso dodtos anr koop. </string> - <string name="new_fragment">New fragment</string> - <string name="fragment_pager_support">Fragment/Pager</string> + <string name="first">First</string> + <string name="last">Last</string> <string name="fragment_state_pager_support">Fragment/State Pager</string> diff --git a/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.java b/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.java index 46288b56e..fcb41cd9c 100644 --- a/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.java +++ b/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentPagerSupport.java @@ -43,7 +43,6 @@ public class FragmentPagerSupport extends Activity { MyAdapter mAdapter; ViewPager mPager; - int mCurPos; @Override protected void onCreate(Bundle savedInstanceState) { @@ -56,15 +55,16 @@ public class FragmentPagerSupport extends Activity { mPager.setAdapter(mAdapter); // Watch for button clicks. - Button button = (Button)findViewById(R.id.new_fragment); + Button button = (Button)findViewById(R.id.goto_first); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { - mCurPos++; - if (mCurPos < NUM_ITEMS) { - mPager.setCurrentItem(mCurPos); - } else { - mCurPos--; - } + mPager.setCurrentItem(0); + } + }); + button = (Button)findViewById(R.id.goto_last); + button.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mPager.setCurrentItem(NUM_ITEMS-1); } }); } diff --git a/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java b/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java index a65d8075b..e19bdf640 100644 --- a/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java +++ b/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java @@ -43,7 +43,6 @@ public class FragmentStatePagerSupport extends Activity { MyAdapter mAdapter; ViewPager mPager; - int mCurPos; @Override protected void onCreate(Bundle savedInstanceState) { @@ -56,15 +55,16 @@ public class FragmentStatePagerSupport extends Activity { mPager.setAdapter(mAdapter); // Watch for button clicks. - Button button = (Button)findViewById(R.id.new_fragment); + Button button = (Button)findViewById(R.id.goto_first); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { - mCurPos++; - if (mCurPos < NUM_ITEMS) { - mPager.setCurrentItem(mCurPos); - } else { - mCurPos--; - } + mPager.setCurrentItem(0); + } + }); + button = (Button)findViewById(R.id.goto_last); + button.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mPager.setCurrentItem(NUM_ITEMS-1); } }); } diff --git a/samples/Support4Demos/res/layout/fragment_pager.xml b/samples/Support4Demos/res/layout/fragment_pager.xml index 3867f46f4..a082e2e54 100644 --- a/samples/Support4Demos/res/layout/fragment_pager.xml +++ b/samples/Support4Demos/res/layout/fragment_pager.xml @@ -28,10 +28,17 @@ android:layout_weight="1"> </android.support.v4.app.FragmentPager> - <Button android:id="@+id/new_fragment" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_weight="0" - android:text="@string/new_fragment"> - <requestFocus /> - </Button> + <LinearLayout android:orientation="horizontal" + android:gravity="center" android:measureWithLargestChild="true" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="0"> + <Button android:id="@+id/goto_first" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="@string/first"> + </Button> + <Button android:id="@+id/goto_last" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="@string/last"> + </Button> + </LinearLayout> </LinearLayout> diff --git a/samples/Support4Demos/res/values/strings.xml b/samples/Support4Demos/res/values/strings.xml index 25fe88088..ba7a341b7 100644 --- a/samples/Support4Demos/res/values/strings.xml +++ b/samples/Support4Demos/res/values/strings.xml @@ -78,6 +78,8 @@ <string name="new_fragment">New fragment</string> <string name="fragment_pager_support">Fragment/Pager</string> + <string name="first">First</string> + <string name="last">Last</string> <string name="loader_cursor_support">Loader/Cursor</string> diff --git a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java index ca5e73f83..3329597b6 100644 --- a/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java +++ b/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java @@ -39,7 +39,6 @@ public class FragmentPagerSupport extends FragmentActivity static final int NUM_ITEMS = 10; FragmentPager mPager; - int mCurPos; @Override protected void onCreate(Bundle savedInstanceState) { @@ -50,15 +49,16 @@ public class FragmentPagerSupport extends FragmentActivity mPager.setAdapter(this); // Watch for button clicks. - Button button = (Button)findViewById(R.id.new_fragment); + Button button = (Button)findViewById(R.id.goto_first); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { - mCurPos++; - if (mCurPos < NUM_ITEMS) { - mPager.setCurrentItem(mCurPos); - } else { - mCurPos--; - } + mPager.setCurrentItem(0); + } + }); + button = (Button)findViewById(R.id.goto_last); + button.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mPager.setCurrentItem(NUM_ITEMS-1); } }); } |