Bonjour à tous

Etant plus que débutant dans la programmation , j'essaie d’acquérir des connaissances en faisant quelque petit projet , Mais là , je ne comprend pas le résultat .

mon .java


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
package com.example.kyuzo.boucling;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import java.text.SimpleDateFormat;
import java.util.Date;
 
public class MainActivity extends AppCompatActivity {
    int nombre1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        Date d = new Date();
        while (nombre1 == 0)
        {
            TextView t2 = (TextView) findViewById(R.id.textView2);
            Button monBouton = (Button)findViewById(R.id.button1);
            SimpleDateFormat f = new SimpleDateFormat("HH:mm:ss");
            String s = f.format(d);
            t2.setText(s);
 
            monBouton.setOnClickListener(new View.OnClickListener()
            {
                @Override
                public void onClick(View v)
                {
                    Toast.makeText(MainActivity.this, "button1 " + nombre1 + " appuyé !", Toast.LENGTH_SHORT).show();
                    nombre1 = 1;
                }
            });
        }
    }
}
mon .xml

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
 
    <TextView android:text="@string/hello_world" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView" />
 
    <TextView
        android:id="@+id/textView2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:textSize="45sp"
        android:textColor="#143dcc"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />
    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/button1"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:color="#143dcc"
        android:textColor="#ff1beb"
        android:alpha="0.50"
        android:layout_alignParentTop="true" />
 
</RelativeLayout>
mon algo souhaité :

faire tant que nombre1 = 0
récupérer les paramètres du layout de button1
récupérer l'heure au format "HH:mm:ss"
afficher l'heure danst2 qui récupére l'affichage de textview t2
quand je clique sur le bouton , nombre1 = 1
qui a pour effet de sortir de la boucle

Mon problème est que depuis que je fait passer mon programme dans la boucle while , j'ai un écran complètement blanc , alors qu'avant j'avais bien l'heure qui s'affichais mais en fixe.

Je vous remercie déjà pour avoir lu jusque ici , puis qui sais , peut etre vous pourriez me venir en aide