我想要达到的是,要有一个有三顿子的主屏幕,取决于哪里,你会从右手上传播相应的看法。 我已使用<条码> 意见书目条码>,并使用<条码>查询书码>。 我得以在下一个观点中动摇。 我希望能够改变下面的观点,以便我能够有与看法一致的县。
I have tried to use ViewFlipper.add()
and ViewFlipper.remove()
to achieve this but to no avail. Could somebody tell me where I m going wrong? Thanks in advance.
以下是我关于<代码>main.xml的守则,每种观点都是单独的布局。
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include
android:id="@+id/main"
layout="@layout/first_view" />
//Do I need these below?
<include
android:id="@+id/first"
layout="@layout/more_info_1" />
<include
android:id="@+id/second"
layout="@layout/more_info_2" />
<include
android:id="@+id/third"
layout="@layout/more_info_3" />
</ViewFlipper>
这里是我的<代码>onCreate()方法:
flipper = (ViewFlipper) findViewById(R.id.flipper);
Button moreInfo1 = (Button) findViewById(R.id.moreinfobutton1);
Button moreInfo2 = (Button) findViewById(R.id.moreinfobutton2);
Button moreInfo3 = (Button) findViewById(R.id.moreinfobutton3);
Button backButton1 = (Button) findViewById(R.id.backbutton1);
Button backButton2 = (Button) findViewById(R.id.backbutton2);
Button backButton3 = (Button) findViewById(R.id.backbutton3);
moreInfo1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(inFromRightAnimation());
flipper.setOutAnimation(outToLeftAnimation());
flipper.showNext();
}
});
moreInfo2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(inFromRightAnimation());
flipper.setOutAnimation(outToLeftAnimation());
//What to put here to change the next View to something else?
flipper.showNext();
}
});
moreInfo3.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(inFromRightAnimation());
flipper.setOutAnimation(outToLeftAnimation());
flipper.showNext();
}
});
backButton1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(inFromLeftAnimation());
flipper.setOutAnimation(outToRightAnimation());
flipper.showPrevious();
}
});
backButton2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(inFromLeftAnimation());
flipper.setOutAnimation(outToRightAnimation());
flipper.showPrevious();
}
});
backButton3.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper.setInAnimation(inFromLeftAnimation());
flipper.setOutAnimation(outToRightAnimation());
flipper.showPrevious();
}
});