Bonjour à tous !
Comme mis dans le titre mon setText() ne marche pas, enfin à moitié..
Celui dans le onCreate() fonctionne très bien, mais celui dans le onTouch() ne s'effectue pas.
Est ce que quelqu'un aurait une solution

Code 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 package a.sd;
 
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.*;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.io.*;
import java.net.Socket;
 
public class MainActivity extends Activity implements View.OnTouchListener
{
    private Socket socket;
    private BufferedReader inFromServer;
    private TextView etat;
 
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
         Button b =(Button) findViewById(R.id.bouton);
         b.setOnTouchListener(this);
         etat=(TextView) findViewById(R.id.etat);
         etat.setText("Etat : déconnecté");
    }
    public boolean onTouch(View view, MotionEvent event){
        String numéro,message;
        String[] donnée;
        Toast toast;
        int i=0;
        try{
                EditText text=(EditText) findViewById(R.id.adIp);
 
                socket=new Socket(text.getText().toString(),17000);
                etat.setText("Etat : connecté");
                setVisible(true);
                toast=Toast.makeText(getApplicationContext(),"Socket créé", Toast.LENGTH_LONG);
                toast.show();
 
		inFromServer = new BufferedReader(new InputStreamReader(socket.getInputStream()));                         
                while(socket!=null){
                    message=inFromServer.readLine();
                    donnée=message.split("#");
                    numéro=donnée[0];
                    message=donnée[1];
 
                    SmsManager sms;
                    sms=SmsManager.getDefault();
                    sms.sendTextMessage(numéro, null, message, null, null);
                    toast=Toast.makeText(getApplicationContext(),"Message envoyé à "+numéro +message, Toast.LENGTH_LONG);
                    toast.show();
                }     
 
 
        }
        catch(Exception e){
            System.out.println(e.getMessage());
        }
        return true;
    }
    public void onDestroy(){
        try{
            socket.close();
            inFromServer.close();
        }
        catch(Exception e){
 
        }
    }
}
LAYOUT :

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
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/ip"
        >
    </TextView>
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/adIp"
        android:inputType="text">
    </EditText>
    <Button
        android:id="@+id/bouton"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center"
        android:text="@string/envoyer" />
    <TextView
        android:id="@+id/etat"
        android:editable="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/etat">
    </TextView>
</LinearLayout>
Merci !