ver2terre Posted February 20, 2012 Share Posted February 20, 2012 Bonjour, je développe une petite appli pour android mais les listener ne font rien, mon code me parait pourtant correct : public class Main extends Activity implements OnClickListener { private Button buttonD = null; private Button buttonB = null; private Button buttonH = null; private EditText txtD = null; private EditText txtB = null; private EditText txtH = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); buttonD = (Button)findViewById(R.id.convertD); buttonB = (Button)findViewById(R.id.convertB); buttonH = (Button)findViewById(R.id.convertH); txtD = (EditText)findViewById(R.id.decimal); txtB = (EditText)findViewById(R.id.binary); txtH = (EditText)findViewById(R.id.hexa); buttonD.setOnClickListener(this); buttonB.setOnClickListener(this); buttonH.setOnClickListener(this); } public void onClick(View v) { switch(v.getId()) { case R.id.convertD: int valD = Integer.parseInt(txtD.getText().toString(),10); txtB.setText(Integer.toBinaryString(valD)); txtH.setText(Integer.toHexString(valD)); break; case R.id.convertB: int valB = Integer.parseInt(txtB.getText().toString(),2); txtD.setText(Integer.toString(valB)); txtH.setText(Integer.toHexString(valB)); break; case R.id.convertH: int valH = Integer.parseInt(txtH.getText().toString(),16); txtD.setText(Integer.toString(valH)); txtB.setText(Integer.toBinaryString(valH)); break; } } } Lorsqu'on clic sur le bouton correspondant, les 2 autres EditText doivent être modifié et converti dans les bases 2/10/16 mais en testant avec l'émulateur, il ne se passe rien en cliquant sur un bouton. Si quelqu'un a une idée.... Link to comment Share on other sites More sharing options...
chpil Posted February 20, 2012 Share Posted February 20, 2012 Ton code semble correct. Peut être un problème dans ton layout ? Peux tu nous le montrer ? Link to comment Share on other sites More sharing options...
ver2terre Posted February 20, 2012 Author Share Posted February 20, 2012 J'ai compris le problème, vu qu'il est étrange... Si je ne fais pas un ant clean avant de recompiler, le .apk semble exactement le même après recompilation (même taille malgrès des modifications dans le .java et après avoir supprimer l'ancien) alors qu'aaprès un ant clean, la taille du apk change bien et mon programme fonctionne..... Quelqu'un à une explication ? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.