how can touch event of different view in single touch can see in below image.
i had try
private void showalert() { dialog = new dialog(this); dialog.requestwindowfeature(window.feature_no_title); dialog.setcontentview(r.layout.temp_view); button btnone = (button) dialog.findviewbyid(r.id.btnone); button btntwo = (button) dialog.findviewbyid(r.id.btntwo); button btnthree = (button) dialog.findviewbyid(r.id.btnthree); btntwo.setfocusableintouchmode(true); btntwo.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { switch (event.getaction()) { case motionevent.action_down: log.e("down", ">>>>>>>>>>>>>button 2 down <<<<<<<<<<<<<<<"); break; case motionevent.action_up: log.e("down", ">>>>>>>>>>>>>button 2 <<<<<<<<<<<<<<<"); break; } return false; } }); btnthree.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { switch (event.getaction()) { case motionevent.action_down: log.e("down", ">>>>>>>>>>>>>button 3 down <<<<<<<<<<<<<<<"); break; case motionevent.action_up: log.e("down", ">>>>>>>>>>>>>button 3 <<<<<<<<<<<<<<<"); break; } return false; } }); btnone.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { switch (event.getaction()) { case motionevent.action_down: log.e("down", ">>>>>>>>>>>>>button 1 down <<<<<<<<<<<<<<<"); break; case motionevent.action_up: log.e("down", ">>>>>>>>>>>>>button 1 <<<<<<<<<<<<<<<"); break; } return false; } }); btnone.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { toast.maketext(temptwittertimelineactivity.this, "one", toast.length_short).show(); } }); view v = dialog.getcurrentfocus(); if (v != null) switch (v.getid()) { case r.id.btnone: toast.maketext(temptwittertimelineactivity.this, "one", toast.length_short).show(); break; case r.id.btntwo: toast.maketext(temptwittertimelineactivity.this, "two", toast.length_short).show(); break; case r.id.btnthree: toast.maketext(temptwittertimelineactivity.this, "three", toast.length_short).show(); break; } dialog.show(); }
but it's work when re-touch other button.
i have activity button, opening custom dialog on button touch event, in custom dialog have 3 button like, share , view call function associate button i.e view profile other second touch, when motionevent.action_up: fire dismiss dialog.
here open dialog code
txttemp.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { switch (event.getaction()) { case motionevent.action_up: if (dialog != null) { if (dialog.isshowing()) { dialog.dismiss(); } } break; } return false; } });
for clear idea here second image enable show touches developer option , take screenshots.
i got 1 cool library in developer make peekandpop view, resolve problem.
below url.
https://android-arsenal.com/details/1/3359
thanks vincent te tau
Comments
Post a Comment