am 47f569e4: Lost and found.

* commit '47f569e460adaef04b75174706b7c95471567ca8':
  Lost and found.
This commit is contained in:
Dianne Hackborn
2011-06-03 13:17:32 -07:00
committed by Android Git Automerger
7 changed files with 54 additions and 38 deletions

View File

@@ -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>

View File

@@ -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>

View File

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

View File

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

View File

@@ -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>

View File

@@ -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>

View File

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