Say I have defined an onClickListener
for a TextView
and I want to trigger it once without having to click on it - Is this possible?
Asked
Active
Viewed 89 times
0

Expo Speta
- 57
- 6
-
You can find the solution here: https://stackoverflow.com/a/18250395/3676200 – Akshay Sethi Oct 25 '19 at 11:57
-
Possible duplicate of [Android call onClick method without Clicking](https://stackoverflow.com/questions/16732398/android-call-onclick-method-without-clicking) – Prasanthvel Oct 25 '19 at 12:34
2 Answers
0
textView= (TextView) findViewById(R.id.button);
textView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Add your code here
}
});
to perform automatic click use below
textView.performClick();

Sajith
- 713
- 6
- 21

Peter Alwin
- 239
- 1
- 6