How to simulate a button click using code?

后端 未结 7 1092
庸人自扰
庸人自扰 2020-12-04 05:27

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 Fac

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 06:18

    Just to clarify what moonlightcheese stated: To trigger a button click event through code in Android provide the following:

    buttonName.performClick();
    

提交回复
热议问题