development
修订版 | a6cadd6244b4c0045ccb571881af982267b4ee9c (tree) |
---|---|
时间 | 2011-06-04 05:17:32 |
作者 | Dianne Hackborn <hackbod@goog...> |
Commiter | Android Git Automerger |
am 47f569e4: Lost and found.
* commit '47f569e460adaef04b75174706b7c95471567ca8':
@@ -28,10 +28,17 @@ | ||
28 | 28 | android:layout_weight="1"> |
29 | 29 | </android.support.v13.view.ViewPager> |
30 | 30 | |
31 | - <Button android:id="@+id/new_fragment" | |
32 | - android:layout_width="wrap_content" android:layout_height="wrap_content" | |
33 | - android:layout_weight="0" | |
34 | - android:text="@string/new_fragment"> | |
35 | - <requestFocus /> | |
36 | - </Button> | |
31 | + <LinearLayout android:orientation="horizontal" | |
32 | + android:gravity="center" android:measureWithLargestChild="true" | |
33 | + android:layout_width="match_parent" android:layout_height="wrap_content" | |
34 | + android:layout_weight="0"> | |
35 | + <Button android:id="@+id/goto_first" | |
36 | + android:layout_width="wrap_content" android:layout_height="wrap_content" | |
37 | + android:text="@string/first"> | |
38 | + </Button> | |
39 | + <Button android:id="@+id/goto_last" | |
40 | + android:layout_width="wrap_content" android:layout_height="wrap_content" | |
41 | + android:text="@string/last"> | |
42 | + </Button> | |
43 | + </LinearLayout> | |
37 | 44 | </LinearLayout> |
@@ -23,9 +23,9 @@ | ||
23 | 23 | siwuf cakso dodtos anr koop. |
24 | 24 | </string> |
25 | 25 | |
26 | - <string name="new_fragment">New fragment</string> | |
27 | - | |
28 | 26 | <string name="fragment_pager_support">Fragment/Pager</string> |
27 | + <string name="first">First</string> | |
28 | + <string name="last">Last</string> | |
29 | 29 | |
30 | 30 | <string name="fragment_state_pager_support">Fragment/State Pager</string> |
31 | 31 |
@@ -43,7 +43,6 @@ public class FragmentPagerSupport extends Activity { | ||
43 | 43 | MyAdapter mAdapter; |
44 | 44 | |
45 | 45 | ViewPager mPager; |
46 | - int mCurPos; | |
47 | 46 | |
48 | 47 | @Override |
49 | 48 | protected void onCreate(Bundle savedInstanceState) { |
@@ -56,15 +55,16 @@ public class FragmentPagerSupport extends Activity { | ||
56 | 55 | mPager.setAdapter(mAdapter); |
57 | 56 | |
58 | 57 | // Watch for button clicks. |
59 | - Button button = (Button)findViewById(R.id.new_fragment); | |
58 | + Button button = (Button)findViewById(R.id.goto_first); | |
60 | 59 | button.setOnClickListener(new OnClickListener() { |
61 | 60 | public void onClick(View v) { |
62 | - mCurPos++; | |
63 | - if (mCurPos < NUM_ITEMS) { | |
64 | - mPager.setCurrentItem(mCurPos); | |
65 | - } else { | |
66 | - mCurPos--; | |
67 | - } | |
61 | + mPager.setCurrentItem(0); | |
62 | + } | |
63 | + }); | |
64 | + button = (Button)findViewById(R.id.goto_last); | |
65 | + button.setOnClickListener(new OnClickListener() { | |
66 | + public void onClick(View v) { | |
67 | + mPager.setCurrentItem(NUM_ITEMS-1); | |
68 | 68 | } |
69 | 69 | }); |
70 | 70 | } |
@@ -43,7 +43,6 @@ public class FragmentStatePagerSupport extends Activity { | ||
43 | 43 | MyAdapter mAdapter; |
44 | 44 | |
45 | 45 | ViewPager mPager; |
46 | - int mCurPos; | |
47 | 46 | |
48 | 47 | @Override |
49 | 48 | protected void onCreate(Bundle savedInstanceState) { |
@@ -56,15 +55,16 @@ public class FragmentStatePagerSupport extends Activity { | ||
56 | 55 | mPager.setAdapter(mAdapter); |
57 | 56 | |
58 | 57 | // Watch for button clicks. |
59 | - Button button = (Button)findViewById(R.id.new_fragment); | |
58 | + Button button = (Button)findViewById(R.id.goto_first); | |
60 | 59 | button.setOnClickListener(new OnClickListener() { |
61 | 60 | public void onClick(View v) { |
62 | - mCurPos++; | |
63 | - if (mCurPos < NUM_ITEMS) { | |
64 | - mPager.setCurrentItem(mCurPos); | |
65 | - } else { | |
66 | - mCurPos--; | |
67 | - } | |
61 | + mPager.setCurrentItem(0); | |
62 | + } | |
63 | + }); | |
64 | + button = (Button)findViewById(R.id.goto_last); | |
65 | + button.setOnClickListener(new OnClickListener() { | |
66 | + public void onClick(View v) { | |
67 | + mPager.setCurrentItem(NUM_ITEMS-1); | |
68 | 68 | } |
69 | 69 | }); |
70 | 70 | } |
@@ -28,10 +28,17 @@ | ||
28 | 28 | android:layout_weight="1"> |
29 | 29 | </android.support.v4.app.FragmentPager> |
30 | 30 | |
31 | - <Button android:id="@+id/new_fragment" | |
32 | - android:layout_width="wrap_content" android:layout_height="wrap_content" | |
33 | - android:layout_weight="0" | |
34 | - android:text="@string/new_fragment"> | |
35 | - <requestFocus /> | |
36 | - </Button> | |
31 | + <LinearLayout android:orientation="horizontal" | |
32 | + android:gravity="center" android:measureWithLargestChild="true" | |
33 | + android:layout_width="match_parent" android:layout_height="wrap_content" | |
34 | + android:layout_weight="0"> | |
35 | + <Button android:id="@+id/goto_first" | |
36 | + android:layout_width="wrap_content" android:layout_height="wrap_content" | |
37 | + android:text="@string/first"> | |
38 | + </Button> | |
39 | + <Button android:id="@+id/goto_last" | |
40 | + android:layout_width="wrap_content" android:layout_height="wrap_content" | |
41 | + android:text="@string/last"> | |
42 | + </Button> | |
43 | + </LinearLayout> | |
37 | 44 | </LinearLayout> |
@@ -78,6 +78,8 @@ | ||
78 | 78 | <string name="new_fragment">New fragment</string> |
79 | 79 | |
80 | 80 | <string name="fragment_pager_support">Fragment/Pager</string> |
81 | + <string name="first">First</string> | |
82 | + <string name="last">Last</string> | |
81 | 83 | |
82 | 84 | <string name="loader_cursor_support">Loader/Cursor</string> |
83 | 85 |
@@ -39,7 +39,6 @@ public class FragmentPagerSupport extends FragmentActivity | ||
39 | 39 | static final int NUM_ITEMS = 10; |
40 | 40 | |
41 | 41 | FragmentPager mPager; |
42 | - int mCurPos; | |
43 | 42 | |
44 | 43 | @Override |
45 | 44 | protected void onCreate(Bundle savedInstanceState) { |
@@ -50,15 +49,16 @@ public class FragmentPagerSupport extends FragmentActivity | ||
50 | 49 | mPager.setAdapter(this); |
51 | 50 | |
52 | 51 | // Watch for button clicks. |
53 | - Button button = (Button)findViewById(R.id.new_fragment); | |
52 | + Button button = (Button)findViewById(R.id.goto_first); | |
54 | 53 | button.setOnClickListener(new OnClickListener() { |
55 | 54 | public void onClick(View v) { |
56 | - mCurPos++; | |
57 | - if (mCurPos < NUM_ITEMS) { | |
58 | - mPager.setCurrentItem(mCurPos); | |
59 | - } else { | |
60 | - mCurPos--; | |
61 | - } | |
55 | + mPager.setCurrentItem(0); | |
56 | + } | |
57 | + }); | |
58 | + button = (Button)findViewById(R.id.goto_last); | |
59 | + button.setOnClickListener(new OnClickListener() { | |
60 | + public void onClick(View v) { | |
61 | + mPager.setCurrentItem(NUM_ITEMS-1); | |
62 | 62 | } |
63 | 63 | }); |
64 | 64 | } |