7

How can I get the text in textswitcher which is previously set. Just like textview.getText(). I have tried the following code but didn't work.

TextSwitcher textSwitcher = (TextSwitcher)findViewById(...);
TextView currentlyShownTextView = (TextView) textSwitcher.getCurrentView();
String currentlyShownText = textSwitcher.getText().toString();
Sagar Zala
  • 4,854
  • 9
  • 34
  • 62
ndn
  • 127
  • 1
  • 12

1 Answers1

14

Refer this answer

TextSwitcher twTime = (TextSwitcher) findViewById(R.id.textSwotcher);
twTime.setCurrentText("your text");
TextView tv = (TextView) twTime.getCurrentView();
if (tv.getText().toString().length()>0) {
    //your action here
}
Community
  • 1
  • 1
SaravInfern
  • 3,338
  • 1
  • 20
  • 44