android - How to press two (or more) buttons at once -
my app has 12 buttons sounds, 1 button can pressed @ once. need enable multitouch in app?
here's code of activity:
import java.io.ioexception; public class myactivity extends activity implements view.ontouchlistener { button button1, button2, button3; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); button1 = (button) findviewbyid(r.id.button); button2 = (button) findviewbyid(r.id.button2); button3 = (button) findviewbyid(r.id.button3); button beatsound1 = (button)this.findviewbyid(r.id.button4); beatsound1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { playsound(beat2); log.d("my", "cow"); } }); button beatsound2 = (button)this.findviewbyid(r.id.button5); beatsound2.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { playsound(beat3); log.d("my", "cow"); } });
in case, far can see, you're working 1 thread. that's problem, guess function playsound()
in same activity, can't execute multiple calls of function @ once without multithreading (which can done asynctask
).
note multitouching not part of developers job, there no way enable more touching capability (this part of hardware). can use 10~ fingers @ once.
Comments
Post a Comment