How do you make an EditText whose original text can only be fully changed?
In the Google Maps app, there's a unique EditText that I'd like to reproduce. If you click "menu" then go to "directions", the "start point" field should begin with "My Location" as the text. The interesting part of this field is its behavior - you cannot edit "My Location" without completely deleting it first.
I have a few places whe开发者_C百科re such behavior would be useful, but I can never quite fully reproduce this. There are three challenges involved with this behavior:
No matter what the user does, they cannot partially edit the field; it is always fully selected.
The keyboard directional keys, rather than moving around the EditText field, change focus.
When the user does choose to change the text, the behavior of #1 and #2 disappear and the field acts like a normal EditText.
Has anyone ever successfully reproduced this behavior?
Isn't it just a hint? Try setting
android:hint="My Location"
on the EditText
in your layout resources.
精彩评论