开发者

String at end of EditText

Is it possible to make an EditText that shows an uneditable string at the end of the user input?

For example, I could have an EditText where I ask for the user's weight in pounds. I know the u开发者_JAVA技巧nits has to be pounds, so if the user enters in "150", then the EditText shows "150 lb", where " lb" is the uneditable string appended at the end of user input.

I'm trying to extend the EditText class, but the TextView setText() method is final, so it can't be overridden, which makes things difficult.


I think before the user tries to enter the data, use hint

<EditText android:hint="@string/hint" />

Once the user completely enters the text and presses the Done button or focuses on the next component on the UI, you can append Lb on the EditText.

Use onFocusChange() listener
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜