【问题标题】:Keypad mobile text want to add through buttons in edittext in android键盘移动文本希望通过 android 中的 edittext 中的按钮添加
【发布时间】:2021-08-28 03:59:32
【问题描述】:

我正在开发一个应用程序,其中设计了一个键盘移动设备,其中添加了一个文本和 12 个按钮 1、2、3..等等。想要添加文本,比如按 2 得到 2、A、B、C,所以应该像文本消息一样输入。坚持这一点有人可以帮我吗?如果有人帮忙,谢谢。

我已经声明了一个 int counter = 0;在按钮上方和按钮上,我使用的是下面的代码。

`
String[] input = {"2","A", "B", "C"};
            if(counter < input.length){
                value = value+(input[counter]);
                //value=value+""+d;
                String e =""+editText.getText().toString();
                editText.setText(value);
                counter++;
            }else {
                counter = 0;
            }

`

【问题讨论】:

  • 你应该至少包含你尝试过的代码
  • 感谢您的评论,我已经添加了代码,但是当我点击按钮 4 次我得到 C 时会发生这种情况,但这并没有单独添加到 edittext 中

标签: java android string android-edittext android-keypad


【解决方案1】:

以这种方式在您的 xml 中编辑文本:

<EditText 
    android:id="@+id/txtOppCodigoCliente"
    android:inputType="textVisiblePassword"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:maxLength="11"
    android:hint="@string/strCodigoCliente"/>

输出: android:inputType="textVisiblePassword"

更多信息:

https://stackoverflow.com/a/14586341/11138845

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-02
    • 2015-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    相关资源
    最近更新 更多