【问题标题】:How to get EditText value to textview at the time of typing without button click in android [closed]如何在没有在android中单击按钮的情况下键入时将EditText值获取到textview [关闭]
【发布时间】:2018-01-03 09:37:29
【问题描述】:

如何在不点击按钮的情况下在用户输入时从 EditText 读取数据到 textview

【问题讨论】:

标签: android android-studio


【解决方案1】:

尝试在 Edittext 上使用 textwatcher 并使用可用方法更新 textview。

TextWatcher textWatcher = new TextWatcher() {
    @Override
    public void beforeTextChanged(CharSequence s, int start, int 
            count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {

    }
};

textView.addTextChangedListener(textWatcher);

【讨论】:

  • 但首先在 textview 中输入数字 remians 请帮忙!!!
  • 好的,先生知道了,如果为零,我必须检查它的长度,然后将文本设置为“”
【解决方案2】:

您可以在编辑文本上添加一个文本观察器,并从那里更新您的文本视图。

【讨论】:

    猜你喜欢
    • 2015-06-09
    • 2020-07-28
    • 2023-02-22
    • 2012-05-19
    • 1970-01-01
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多