开发者

Problem with ViewFlipper

i have an XMl file that includes a ViewFlipper, and want to show the next view(in the viewflipper) after 3 seconds, but it doesn't shows after this period: 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">
    <RelativeLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView android:id="@+id/sipLabel" android:textSize="20sp"
            android:layout_width="fill_parent" android:layout_height="wrap_content" />
        <ImageView android:id="@+id/disconnected" android:src="@drawable/disconnected"
            android:layout_below="@id/sipLabel" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="0.35"
            android:gravity="center" android:visibility="visible" />
    </RelativeLayout>
    <RelativeLayout android:layout_width开发者_开发百科="fill_parent"
        android:layout_height="fill_parent">
        <TextView android:id="@+id/sipLabel" android:textSize="20sp"
            android:layout_width="fill_parent" android:layout_height="wrap_content" />
        <ImageView android:id="@+id/connected" android:src="@drawable/connected"
            android:layout_below="@id/sipLabel" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="0.35"
            android:gravity="center" android:visibility="visible" />
    </RelativeLayout>
</ViewFlipper>

JAVA code:

public void onRegistrationDone(String localProfileUri, long expiryTime)
{
    updateStatus("Registered to server.");
    Log.d("SUCCEED", "Registration DONE");

    final ViewFlipper flipper = (ViewFlipper) findViewById(R.id.flipper);
    flipper.postDelayed(new Runnable()
    {
        public void run()
        {
            flipper.showNext();
        }
    }, 3000);
}

What is the problem ? why the next view doesn't shows ?

Thank you for your help.


try this insted of runnig a thread:

viewFlipper.setFlipInterval(FLIP_INTERVAL);
viewFlipper.startFlipping();

you can set the FLIP_INTERVAL in milisecond.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜