【问题标题】:How to set cursor position after hint message in TextInputEditText如何在 TextInputEditText 中的提示消息后设置光标位置
【发布时间】:2019-06-10 07:31:31
【问题描述】:

如何将光标位置设置在提示消息的右侧。

完整的代码在这里

         <android.support.design.widget.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="1dp"
                android:hint="@string/_254"
                android:inputType="phone"/>

【问题讨论】:

  • 是否要将提示文本用作用户需要编辑的默认文本?
  • 是的,用户可以编辑
  • 您发布的答案不能解决您的问题。

标签: android layout


【解决方案1】:

这就是我设法解决问题的方法`

**java **

final EditText edit = findViewById(R.id.hint);
edit.requestFocus();
edit.setSelection(edit.length()-0);

`

【讨论】:

    【解决方案2】:

    提示的使用是预先输入 EditText 并且当用户输入提示时将被用户的条目替换

    也许您想改用android:text 或者您可以使用setSelection() 方法将光标放在正确的位置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-23
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多