hellogoodbye Posted August 1, 2011 Share Posted August 1, 2011 Salut, j'ai un soucis, je souhaiterai mettre plusieurs boutons dans un même code java/android et je ne comprends pas pourquoi cela ne fonctionne pas, ou plutôt cela fonctionne pour le premier mais pas pour le second. Pour le second, cela me dit: "void is an invalid type for the variable onClick". Je ne comprends pas car c'est un type valide pour le premier bouton. Merci de votre aide. Hellogoodbye PS: Je vous joint mon extrait de code: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_screen); Click = (Button)findViewById(R.id.click); Name = (EditText)findViewById(R.id.name); Click.setOnClickListener(this); } @Override public void onClick(View vClick) { if (vClick == Click && !Name.getText().toString().equals("") && !Name.getText().toString().equals("teacher")) { setContentView(R.layout.explications); LetsPlay = (Button)findViewById(R.id.letsplay); LetsPlay.setOnClickListener(this); @Override public void onClick(View vLetsPlay){ } } } Link to comment Share on other sites More sharing options...
hellogoodbye Posted August 2, 2011 Author Share Posted August 2, 2011 Bon j'ai eu la réponse sur un autre forum: En créant des OnClickListener sur tes boutons cela serait mieux pour que cela marche ! Ici il n'y as que 1 listener (alors que j'en veux plusieurs) http://developer.android.com/referen...et/Button.html cordialement , 1 - identifier par son ID le bouton pressé : OnClickListener 2 - void Onclick : On défini l'action à faire en réponse Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.