2011-05-01 3 views
0

Je dispose d'un fichier .xml qui comprend un ViewFlipper, et que vous souhaitez afficher la vue suivante (dans le viewflipper) au bout de 3 secondes, mais il ne montre après cette période: XML:problème ViewFlipper

<?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> 

code 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); 
} 

Quel est le problème? pourquoi la vue suivante ne montre pas?

Nous vous remercions de votre aide.

+0

Ah ok j'ai @ drawable/connecté dans les deux vues! cependant le textview ne s'affiche pas dans la deuxième vue, j'ai juste l'image! une idée ? Merci. – androniennn

+0

êtes-vous certain que 'onRegistrationDone' est en cours d'exécution dans le thread UI? Si c'est le cas, à moins que la méthode 'updateStatus' ne lance une exception, ce code fonctionne bien! – rekaszeru

Répondre

0

essayer cette insted de runnig un fil:

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

vous pouvez définir le FLIP_INTERVAL dans milisecond.