j'ai réalisé une CheckBox et un EditText.
j'ai mis l'EditText en .setFocusable(false). Je souhaite quand je select le CheckBox, l'EditText se met en .setFocusable(true).

Le 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
 
public class AjoutProduits extends Activity{
	EditText qte1,qte2;
        CheckBox CheckBox1,CheckBox2; 
 
    @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.ajoutproduits);
qte1 = (EditText) findViewById(R.id.editText3);
 qte2 = (EditText) findViewById(R.id.editText4);
 
 
 qte1.setFocusable(false);
 qte2.setFocusable(false);
 
 CheckBox1 = (CheckBox) findViewById(R.id.checkbox1);
 CheckBox2 = (CheckBox) findViewById(R.id.checkbox2);
 
 CheckBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
 
     @Override
     public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
 
         if(CheckBox1.isChecked()){
        	 qte1.setFocusable(true);
         }
         else{
        	 qte1.setFocusable(false);}
     }
 });
 
CheckBox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
 
     @Override
     public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
 
         if(CheckBox2.isChecked()){
        	 qte2.setFocusable(true);
         }
         else{
        	 qte2.setFocusable(false);}
     }
 });
mon fichier 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
 
<TableRow>
        <CheckBox
        android:id="@+id/checkbox1"
        android:padding="3dip"/>
 
 
        <EditText
        android:id="@+id/editText3"
        android:hint="Entrez la Qte1"
        android:gravity="right"
        android:padding="3dip" />
    </TableRow>
 
 
    <TableRow>
        <CheckBox
     android:id="@+id/checkbox2"
     android:padding="3dip"/>
 
 
        <EditText
        android:id="@+id/editText4"
        android:hint="Entrez la Qte2"
        android:gravity="right"
        android:padding="3dip" />
    </TableRow>
l'affichage des élèments de fichier XML marche bien. Mon problème est lorsque je select le checkBox , l'état de l'Edit Text ne change pas??
Le logcat n'affiche aucun erreur.

Merci pour votre aide.