Afficher/masquer une image
Bonjour,
Je suis débutant sous Android et j'essaie de faire apparaitre une image quelques secondes après le lancement de l'appli.
Mon fichier xml contient ceci:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Toolbar"
android:src="@drawable/toolbar"
android:visibility="visible" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="bulle"
android:src="@drawable/testbulle"
android:visibility="invisible" />
</LinearLayout> |
Pour afficher la seconde image, j'ai ajouté ce code dans mon fichier java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
@Override
protected void onStart(){
super.onStart();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ImageView iv=(ImageView)findViewById(R.id.imageView2);
iv.setVisibility(ImageView.VISIBLE);
} |
Le but étant de faire une pause de 5s après lancement et d'afficher la 2nde image.
Le problème est que la première image reste invisible tant que la 2nde n'est pas affiché. J'ai essayé de déplacer ce code dans onResume(), mais c'est pareil.
Quelqu'un a-t-il une piste?