Examples of Android resolution button repeat click _android

Source: Internet
Author: User

  To prevent a button from being clicked by the user or by testing mm, write a method to prevent a continuous click of the buttons. The concrete instance code looks like this:

 public class Baseactivity extends activity {protected Boolean Isdestroy; 
The flag to prevent repeated clicks is set to False when clicking on other activity, set to True private Boolean clickable=true in the Onresume event; 
@Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); 
Isdestroy=false; 
Requestwindowfeature (Window.feature_no_title); 
Setrequestedorientation (activityinfo.screen_orientation_portrait); 
} @Override protected void OnDestroy () {Super.ondestroy (); 
Isdestroy=true; 
} @Override protected void Onresume () {super.onresume (); 
Each time you return to the interface, the click flag is set to clickable clickable=true; 
/** * can currently click * @return/protected Boolean isclickable () {return clickable; 
/** * Lock Click * * protected void Lockclick () {clickable=false; @Override public void Startactivityforresult (Intent Intent, int requestcode, Bundle options) {if (isclickable ()) {L 
Ockclick (); 
Super.startactivityforresult (Intent, requestcode,options); } 
} 
} 

Through a simple piece of code to introduce you to the Android button repeat click Problem, I hope you like.

Related Article

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.