It may seem an absurd question, but I would like to be able to call the code associated with the event of pressing a specific button.
I've been looking for information and I see nothing that can help me.
Example of what I want:
final ImageView img23 = (ImageView) vTweets.findViewById(R.id.ImageView01);
img23.setId(t);
img23.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//I need to use this code without the user press the button//
}
});
public void example(){
//Here I need to use the code that is inside the onclick event//
}
Thanks
public void example(){
img23.performClick();
}
Why not create a function that will do the stuff that is required by the on click and then in your on click method call the function. Makes no sense to effectively duplicate the code once in a function and inside the onclick function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With