【问题标题】:Get user input in Android app to change TextView text在 Android 应用中获取用户输入以更改 TextView 文本
【发布时间】:2013-10-30 20:49:32
【问题描述】:

我有一个带有一些默认文本的TextView,但是当存在特定文件时,它应该提示用户输入 TextView 的新文本。有没有简单的方法来做到这一点?

我知道 if 语句应该是什么,但不知道如何获得用户响应。

在 JavaScript 中我会这样做:

var newText = prompt("What should the new text be?");
myElement.text = newText;

【问题讨论】:

  • edittext 有什么问题???虽然你可以在 textview 上调用 setText 方法
  • TextView 像按钮一样使用。

标签: java android dialog prompt


【解决方案1】:

使用包含EditTextDialog/DialogFragment(可能还有一些进一步的验证)来获取用户的输入。

This Android-Developers blog post 完全涵盖了这种情况,应该可以回答您的所有问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-03
    • 2020-10-05
    • 1970-01-01
    • 1970-01-01
    • 2013-07-18
    • 2011-01-19
    • 2016-08-06
    • 1970-01-01
    相关资源
    最近更新 更多