I am Sathya and i am new to android. And i have a doubt that how to disable a button for 5 minutes after log in attempt failed. Even the user close the app and open it again after 2 minutes, then the button should be disable for balance 3 minutes. How to do this. Any please send me some examples.
Asked
Active
Viewed 1,090 times
2 Answers
0
Hi look at these post (You need to combine these two things) :
In the first post you see how to disable a button in android
myButton.setEnabled(false);
And in the second post you see how to make a timer
Community
- 1
- 1
Orelsanpls
- 20,654
- 4
- 36
- 61
0
Well I can say that you'll need a Handler, and something to get the actual time for your 2nd question. You get a Handler like this:
Handler handler = new Handler();
final Runnable r= new Runnable(){
@Override
public void run(){
if(time < 0){
button.setEnabled(true);
}
handler.postDelayed(this, 1000); //This runs the code again
}
};
handler.postDelayed(r, 1000); //This runs the Handler.
The 1000 means miliseconds. Which means it will read the code for every 1000 miliseconds = 1 second. You still need to find a way to get the actual time. That's just an example of the handler.
If the user is wrong when putting the password:
button.setEnabled(false);
user6345865
- 53
- 7