【问题标题】:Getting text from TextSwitcher从 TextSwitcher 获取文本
【发布时间】:2016-11-21 06:29:43
【问题描述】:

如何获取之前设置的 textswitcher 中的文本。就像 textview.getText() 一样。我已经尝试了以下代码,但没有奏效。

TextSwitcher textSwitcher = (TextSwitcher)findViewById(...);
TextView currentlyShownTextView = (TextView) textSwitcher.getCurrentView();
String currentlyShownText = textSwitcher.getText().toString();

【问题讨论】:

    标签: android textview textswitcher


    【解决方案1】:

    参考this答案

    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
    }
    

    【讨论】:

      猜你喜欢
      • 2020-08-31
      • 2022-12-12
      • 1970-01-01
      • 2012-10-13
      • 2012-07-19
      • 2022-01-01
      • 1970-01-01
      • 2014-01-03
      相关资源
      最近更新 更多