MelonSmasher
MelonSmasher

Reputation: 670

Button automatically click?

I need to have a button automatically click. Either on the creation of the activity, or on a timer that I will set to a very short time. Can anyone help me out with this. How do I call for the button to be clicked?

Upvotes: 2

Views: 12085

Answers (7)

Jatin Devani
Jatin Devani

Reputation: 190

you can use inbuild method of button buttonName.callOnClick()

Upvotes: 0

Finava Vipul
Finava Vipul

Reputation: 998

work for me please use this

button.callOnClick();

Upvotes: -1

Biswajit Karmakar
Biswajit Karmakar

Reputation: 9897

yourbutton.post(new Runnable(){
            @Override
            public void run() {
                 mybutton.performClick();
            }
});

Upvotes: -1

Pradeep Sodhi
Pradeep Sodhi

Reputation: 2145

Put all the code of your button in OnCreate() and change the button background so it looks like clickable when your activity start..

Upvotes: 0

Jack Long
Jack Long

Reputation: 69

if you want to on Click automatic . Please call ButtonName.performClick(); NOTE : you must Setonclick for that Button

Upvotes: 1

wsanville
wsanville

Reputation: 37516

You can call the OnClickListener (if any) using performClick().

Upvotes: 9

Ashwinee K Jha
Ashwinee K Jha

Reputation: 9307

You can try calling onClick() method of the button.

Upvotes: 0

Related Questions