android - clicklistener and longclicklistener on the same button? -
i creating call/dial button, when click on call/dial button, call made based on input displayed in edittext. managed part. can guys advise me whether can longer click on same call/dial button, toast can come out ask user choose else??
i did research on "setonlongclicklistener" not sure if can combine in same call/dial button? have attached on working dial function managed do, wondering if "setonlongclicklistener" can combined somehere in code?
private void dialanumber() { try { buttoncall = (imagebutton) findviewbyid(r.id.imagebutton2); buttoncall.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { // todo auto-generated method stub if (display != null) { intent callnumber = new intent(); callnumber .setaction(android.content.intent.action_call); callnumber.setdata(uri.parse("tel:" + display.gettext())); startactivity(callnumber); } } }); } catch (activitynotfoundexception anfe) { log.e("dialanumber", "dialing number failed", anfe); }
this code working. hope longer click can made on same call/dial button button can have normal click make call, , longer click pop out toast. in advance.
note returning "false" on long click listener have ui responding long click short click too. return "true" if want kill off. "true" means "yes, used event" , "false" means "whether used or not, environment free respond well." (i know because used akashg's answer in own app.)
Comments
Post a Comment