Tuesday, August 21, 2018

Android invoking View Click through code

Invoking click event on all the views (Buttons, Layout etc.,) through code can be done so easily.
Method 1
Call performClick() function on the view for which you want to perform click event
Button btnSend = findViewById(R.id.btnSend);
LinearLayout layoutContainer = findViewById(R.id.container);
// perform click on button
btnSend.performClick();
// perform click on Linear Layout
layoutContainer.performClick();

No comments:

Post a Comment

AJAX - Quick Guide