English 中文(简体)
下调观点,见GisFlaper
原标题:Changing which View is next to show in ViewFlipper

我想要达到的是,要有一个有三顿子的主屏幕,取决于哪里,你会从右手上传播相应的看法。 我已使用<条码> 意见书目,并使用<条码>查询书码>。 我得以在下一个观点中动摇。 我希望能够改变下面的观点,以便我能够有与看法一致的县。

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();      
         }
     });
最佳回答

使用<条码> 密码> 查询

public void removeViewAt (int index)
public void addView (View child, int index, ViewGroup.LayoutParams params)

这将使你能够消除某种观点,不要再需要,再增加另一种观点。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签