ViewFlipper的奇怪问题

| 我有一个ViewFlipper,它显示2个imageview(断开连接时为红色,连接时为绿色),但是,我得到一个奇怪的结果:有时在连接时显示红色图像,它的开关如下:red-green -并返回红色(即使我已连接)。 这是JAVA代码:
public void onRegistrationDone(String localProfileUri, long expiryTime) {

                        updateStatus(\"Enregistré au serveur.\");
                        Log.d(\"SUCCEED\",\"Registration DONE\");

                        final ViewFlipper flipper = (ViewFlipper)findViewById(R.id.flipper);
                        flipper.postDelayed(new Runnable() {
                        public void run() {
                        flipper.showNext();
                            }
                        },2000);}
该视图以红色图像开始,然后在连接时(2秒后)正常显示下一个图像。 可能是什么问题呢? 非常感谢你。 编辑:XML文件(处理程序)
<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:orientation=\"vertical\" 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/status\"  android:layout_below=\"@id/sipLabel\" 
  android:layout_width=\"fill_parent\" android:scaleType=\"center\"
        android:layout_height=\"fill_parent\" android:layout_weight=\"0.35\" android:gravity=\"center\"

         />
        </LinearLayout>
    
已邀请:
我会做不同的事情。如果那只是显示不同图像(红色/绿色)的问题,我将使用ImageView UI控件显示该图像。对于延迟的显示更新,您可以使用Handler。像这样:
public void onRegistrationDone(String localProfileUri, long expiryTime) 
{
    updateStatus(\"Enregistré au serveur.\");
    Log.d(\"SUCCEED\",\"Registration DONE\");

    mRegistered = true;
    mRegistrationUpdateHandler.removeCallbacks(handleUpdateStatus);
    mRegistrationUpdateHandler.postDelayed(handleUpdateStatus, 2000);
}

public void onRegistrationLost()
{
    mRegistered = false;
    mRegistrationUpdateHandler.removeCallbacks(handleUpdateStatus);
    mRegistrationUpdateHandler.postDelayed(handleUpdateStatus, 2000);
}

private Runnable handleUpdateStatus = new Runnable() 
{     
    public void run()
    {
        ImageView statusImageDisplay = (ImageView)findViewById(R.id.statusImage);
        if (mRegistered)
        {
            statusImageDisplay.setImageDrawable(getResources().getDrawable(R.drawable.imageGreen));
        else
        {
            statusImageDisplay.setImageDrawable(getResources().getDrawable(R.drawable.imageRed));
        }
    }
};  
    

要回复问题请先登录注册