ndn*_*ndn 4 android textview textswitcher
如何获取之前设置的textswitcher中的文本.就像textview.getText()一样.我尝试了以下代码,但没有奏效.
TextSwitcher textSwitcher = (TextSwitcher)findViewById(...);
TextView currentlyShownTextView = (TextView) textSwitcher.getCurrentView();
String currentlyShownText = textSwitcher.getText().toString();
Run Code Online (Sandbox Code Playgroud)
请参阅此答案
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
}
Run Code Online (Sandbox Code Playgroud)