Android: Two buttons but the action from pressing one is only taking place after the other is pressed too -
i have 2 buttons in application, 1 to start google voice , other exit application. however, when press voice button, doesn't until after press exit button too. so, app exits, google voice starts.
public void onclick(view v) { switch(v.getid()){ case r.id.btndisable:{ //set ringer normal audio.setringermode(2); //close text-to-speech engine tts.shutdown(); //welcome.bt.disable(); activity.finish(); ondestroy(); break; } case r.id.btnvoice: { system.out.println ("pressed"); intent intent = new intent(recognizerintent.action_recognize_speech); intent.putextra(recognizerintent.extra_language_model, "en_us"); try { startactivityforresult(intent, result_speech); } catch (activitynotfoundexception a) { toast t = toast.maketext(getapplicationcontext(), "opps! device doesn't support speech text", toast.length_short); t.show(); } break; } } }
try sample, works properly, adjust names according xmls , files, you'll manage part
public class findeventsactivity extends activity implements onclicklistener{ //lots of other code here public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.adds); findviewbyid(r.id.badd).setonclicklistener(this); findviewbyid(r.id.bsub).setonclicklistener(this); } public void onclick(view v) { switch(v.getid()){ case r.id.badd: //set ringer normal system.out.println("button 1"); break; case r.id.bsub: system.out.println ("button 2"); break; } } }
if still don't see problem share more code.
hope helps , enjoy work
Comments
Post a Comment