sam sam - 1 year ago 164
Android Question

How to simulate a button click using code?

How can I trigger a button click event using code in Android? I want to trigger the button click programmatically when some other event occurs.

Same Problem I am Facing

public void onDateSelectedButtonClick(View v){
/*Something Alarm Management
copied code from this site*/

Button code:

android:text="Set notification for this date" />

But I want to call that function OnLoadLayout without OnClickEvent

Answer Source

there is a better way.


this should answer all your problems. every View inherits this function, including Button, Spinner, etc.