关于ViewFlipper的有关问题,在同一个页面有两个layout,当滑动到第二个view的时候吗,怎样监听返回键返回到上一个layout,而不关闭页面
关于ViewFlipper的问题,在同一个页面有两个layout,当滑动到第二个view的时候吗,怎样监听返回键返回到上一个layout,而不关闭页面~
如题。。。代码如下
<ViewFlipper
android:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:flipInterval="1000"
android:inAnimation="@anim/push_left_in"
android:outAnimation="@anim/push_left_out"
android:persistentDrawingCache="animation" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/Button_next1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next" >
</Button>
<ImageView
android:id="@+id/image1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" >
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/Button_next2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next" >
</Button>
<ImageView
android:id="@+id/image2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/logo" >
</ImageView>
</LinearLayout>
</ViewFlipper>
public class MainActivity extends Activity {
private ViewFlipper mViewFlipper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonNext1 = (Button) findViewById(R.id.Button_next1);
mViewFlipper = (ViewFlipper) findViewById(R.id.details);
buttonNext1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// 在layout中定义的属性,也可以在代码中指定
// mViewFlipper.setInAnimation(getApplicationContext(),
// R.anim.push_left_in);
// mViewFlipper.setOutAnimation(getApplicationContext(),
// R.anim.push_left_out);
// mViewFlipper.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES);
// mViewFlipper.setFlipInterval(1000);
mViewFlipper.showNext();
// 调用下面的函数将会循环显示mViewFlipper内的所有View。
// mViewFlipper.startFlipping();
}
});
Button buttonNext3 = (Button) findViewById(R.id.Button_next3);
buttonNext3.setOnClickListener(new View.OnClickListener() {
如题。。。代码如下
<ViewFlipper
android:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:flipInterval="1000"
android:inAnimation="@anim/push_left_in"
android:outAnimation="@anim/push_left_out"
android:persistentDrawingCache="animation" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/Button_next1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next" >
</Button>
<ImageView
android:id="@+id/image1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" >
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/Button_next2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next" >
</Button>
<ImageView
android:id="@+id/image2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/logo" >
</ImageView>
</LinearLayout>
</ViewFlipper>
public class MainActivity extends Activity {
private ViewFlipper mViewFlipper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonNext1 = (Button) findViewById(R.id.Button_next1);
mViewFlipper = (ViewFlipper) findViewById(R.id.details);
buttonNext1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// 在layout中定义的属性,也可以在代码中指定
// mViewFlipper.setInAnimation(getApplicationContext(),
// R.anim.push_left_in);
// mViewFlipper.setOutAnimation(getApplicationContext(),
// R.anim.push_left_out);
// mViewFlipper.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES);
// mViewFlipper.setFlipInterval(1000);
mViewFlipper.showNext();
// 调用下面的函数将会循环显示mViewFlipper内的所有View。
// mViewFlipper.startFlipping();
}
});
Button buttonNext3 = (Button) findViewById(R.id.Button_next3);
buttonNext3.setOnClickListener(new View.OnClickListener() {