Different reactions to the length and duration of Android

Source: Internet
Author: User

When we want to enable a ListView to handle both long-press events and short-press events at the same time, you can set its Onitemlongclicklistener

and Onitemclicklistener. It is important to note that the Onitemlongclick inside the Onitemlongclicklistener to return True,

The short press event is also activated when a long press event is active.

Examples are as follows:

Listview.setonitemlongclicklistener (NewOnitemlongclicklistener () { Public BooleanOnitemlongclick (adapterview<?> Parent, view view,intPositionLongID) {Toast.maketext (Getapplicationcontext (),"Long Click", Toast.length_long). Show (); return true;                }        }); Listview.setonitemclicklistener (NewOnitemclicklistener () {@Override Public voidOnitemclick (adapterview<?> arg0, View arg1,intArg2,LongArg3) {                //TODO auto-generated Method StubToast.maketext (Getapplicationcontext (), "Short Click", Toast.length_long). Show (); }        });

Different reactions to the length and duration of Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.