androniennn Posted November 27, 2010 Share Posted November 27, 2010 Bonsoir, Je débute sur le développement des applications sur Android, j'ai commencé par le fameux HelloWorld et maintenant j'attaque le développement d'une calculatrice, et j'ai besoin de votre aide: Voila le code source que j'ai fait: package calc.android.com; import android.app.Activity; import android.os.Bundle; import android.text.Editable; import android.text.GetChars; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Toast; public class Calc extends Activity { private EditText text1,text2; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); text1 = (EditText) findViewById(R.id.EditText01); text2 = (EditText) findViewById(R.id.EditText02); } public void myClickHandler(View view) { final CheckBox addbutton = (CheckBox) findViewById(R.id.CheckBox01); final CheckBox sousbutton = (CheckBox) findViewById(R.id.CheckBox02); final CheckBox mulbutton = (CheckBox) findViewById(R.id.CheckBox03); final CheckBox divbutton = (CheckBox) findViewById(R.id.CheckBox04); int x; int z; int y; if (text1.getText().length() == 0) { Toast.makeText(this,"Please enter a valid number in 1", Toast.LENGTH_LONG).show(); return; } if (text2.getText().length() == 0) { Toast.makeText(this,"Please enter a valid number in 2", Toast.LENGTH_LONG).show(); return; } if (addbutton.isChecked()) { x=text1.getText(); y=text2.getText(); z=x+y; } } } Problème: une erreur sur les text1.getText() et text2.getText() : Type mismatch: cannot convert from editable to int . Sachant que j'ai indiqué que les 2 champs sont de type numbersigned, numberdecimal ! Il me propose de changer le type des 3 variables(x,y,z) à Editable !! Merci de m'aider :) . Link to comment Share on other sites More sharing options...
Profete162 Posted November 27, 2010 Share Posted November 27, 2010 Juste une remarque en vitesse: text.getText().toString(); J'espèere que je dis pas une connerie car je passe en vitesse ce soir... Link to comment Share on other sites More sharing options...
arnouf Posted November 29, 2010 Share Posted November 29, 2010 Juste une remarque en vitesse: text.getText().toString(); J'espèere que je dis pas une connerie car je passe en vitesse ce soir... +1 avec ça Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.