我有一个包含ViewFlipper的XMl文件,并希望在3秒后显示下一个视图(在viewflipper中),但在这段时间后它没有显示: 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代码:
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);
}问题出在哪里?为什么下一个视图没有显示?
谢谢你的帮助。
发布于 2014-11-09 14:43:36
试试这个运行线程的实例:
viewFlipper.setFlipInterval(FLIP_INTERVAL);
viewFlipper.startFlipping();您可以以毫秒为单位设置FLIP_INTERVAL。
https://stackoverflow.com/questions/5848637
复制相似问题