I have a ViewFlipper that shows 2 imageview (red one when disconnected and the green other when connected), however, i have a strange result: sometimes the red image is showen when i’m connected, it switches like this : red-green-and returns red(even when i’m connected).
Here is the JAVA code:
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);}
The view is initiated with the red image, then, when connected(and after 2 seconds) the next image is normally showen.
What could be the problem?
Thank you very much.
EDIT: XML file (Handler)
<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>
I would do that differently. If that is just a matter of displaying different image (red/green) I would use ImageView UI control to display that image. And for the delayed display update you may use Handler. Something like this: