How to simulate a button click using code?

后端 未结 7 1053
庸人自扰
庸人自扰 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:26

    Android's callOnClick() (added in API 15) can sometimes be a better choice in my experience than performClick(). If a user has selection sounds enabled, then performClick() could cause the user to hear two continuous selection sounds that are somewhat layered on top of each other which can be jarring. (One selection sound for the user's first button click, and then another for the other button's OnClickListener that you're calling via code.)

    0 讨论(0)
提交回复
热议问题