Through out the whole android application I want to capture button click, radio button clicks, link click etc… basically a user interaction in whole android application. Is there any common method to detect which element user click and its values.?
- July 20, 2021
- 266 views
- 3 votes
- 4 Answers
-
4
Answers
Try using onCickListener() on the buttons.
In Kotlin:
android:id="@+id/nameOfButton"
. Every button needs an unique name.setOnClickListener
with the id to set up the action when user click the button.Example:
step 1
step 2
Its very simple you just need to get the text and id of button from the onclick method. Here is java and xml code for it:
XML:
JAVA:
As @Muthukumar Lenin asked here is listview in xml and java
XML:
JAVA:
Some of these code are from tutorialspoint and some are edited by me.