bonjour ,

Pas d'erreur de syntaxe sur les lignes suivantes , mais il n'y a que
Button Resist qui calcule R=T/I

Button Intens ( I =T/R ) , Button Tension ( T=R*I ) ne sont pas actif
et ne déclenchent rien dans le champs text correspondant

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
package msi_ubuntu.multimetre;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
 
import static msi_ubuntu.multimetre.R.layout;
 
public class MainActivity extends Activity {
 
    //On déclare toutes les variables dont on aura besoin
    Button buttonR;
    Button buttonT;
    Button buttonI;
    EditText ecranR;
    EditText ecranT;
    EditText ecranI;
 
 
    /**
     * Activité de l'interface graphique
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(layout.activity_main);
 
        //On récupère tous les éléments de notre interface graphique grâce aux ID
        // ******** DEFINITION DES CONSTANTES ET VARIABLES  ********************
        Button Resist = (Button) findViewById(R.id.button);
        Button Tension = (Button) findViewById(R.id.button2);
        Button Intens  = (Button) findViewById(R.id.button3);
        final EditText EcranR = (EditText) findViewById(R.id.editText);
        final EditText EcranT = (EditText) findViewById(R.id.editText2);
        final EditText EcranI = (EditText) findViewById(R.id.editText3);
 
        // ***************  ATTRIBUT  *************************
        //On attribue un écouteur d'évènement à bouton R=T/I
        Resist.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                double result= new Double(EcranT.getText().toString())
                    / new Double(EcranI.getText().toString());
                EcranR.setText(Double.toString(result));
            }
        });
        //On attribue un écouteur d'évènement à bouton T=R*I
        Tension.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                double result= new Double(EcranR.getText().toString())
                        * new Double(EcranI.getText().toString());
                EcranT.setText(Double.toString(result));
            }
        });
        //On attribue un écouteur d'évènement à bouton I=T/R
        Intens.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                double result= new Double(EcranT.getText().toString())
                        / new Double(EcranR.getText().toString());
                EcranI.setText(Double.toString(result));
            }
        });
    }
 
}