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.?
Question posted in Android Studio
The official documentation can be found here.
The official documentation can be found here.
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.