The click on a button or View is usually called when the user clicks on it. But how can we call it programatically. Here is a simple example

Button btnClick = findViewById(R.id.btnClick);
LinearLayout mLayout = findViewById(R.id.mLayout);
 
// perform click on button
btnClick.performClick();
 
// perform click on Linear Layout
mLayout.performClick();

yes “performClick()”, this is how to call click programatically.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.