android edit text some text always there not editable - stack overflow.pdf

Upload: shoaib-quraishi

Post on 28-Feb-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Android Edit Text Some Text Always there not editable - Stack Overflow.pdf

    1/4

    Stack Overflow sign up log in

    Questions Tags Use rs Badge s Unanswe red Ask

    1 Android Edit Text Some Text Always there not editable

    android android-edittext

    I want to put some custom text on EditText. Which would be non editable And always appear on edit text.When we add something on edit text my noneditable text should move forward.

    Something like this should appear by default

    Non editable Text

    And when i type something on edit text it should appear like this

    Hello World Non editable Text

    There is a programmatical approach to this. I'll write up an answer in a bit once I figure it out. But here is another way to do it: stackoverflow.com/questions/17517278/ mike yaworskiNov 20 '13 at 1:02

    could you please take a look at my answer and see if it works for you. Leave a comment with some feedback. mike yaworskiNov 20 '13 at 20:51

    Read this post in our app!

    share improve this question

    AskedNov 20 '13 at 0:09

    Nouman Ahmad

    8

    3

    EditedMar 2 at 7:43

    Cactus

    12.2k

    6

    32

    70

    http://stackoverflow.com/posts/20084892/edithttp://stackoverflow.com/posts/20084892/edithttp://stackoverflow.com/posts/20084892/edithttp://stackoverflow.com/questions/tagged/androidhttp://stackoverflow.com/questions/tagged/androidhttp://stackoverflow.com/questions/tagged/android-edittexthttp://stackexchange.com/http://stackexchange.com/http://stackoverflow.com/http://stackoverflow.com/users/477476/cactushttp://stackoverflow.com/users/477476/cactushttp://stackoverflow.com/posts/20084892/revisionshttp://stackoverflow.com/users/3010984/nouman-ahmadhttp://stackoverflow.com/users/3010984/nouman-ahmadhttp://stackoverflow.com/posts/20084892/edithttp://stackoverflow.com/q/20084892http://stackexchange.com/http://stackoverflow.com/users/2554605/mike-yaworskihttp://stackoverflow.com/users/2554605/mike-yaworskihttp://stackoverflow.com/questions/17517278/editbox-hint-always-show-hinthttp://stackoverflow.com/questions/tagged/android-edittexthttp://stackoverflow.com/questions/tagged/androidhttp://stackoverflow.com/questions/20084892/android-edit-text-some-text-always-there-not-editablehttp://stackoverflow.com/questions/askhttp://stackoverflow.com/unansweredhttp://stackoverflow.com/help/badgeshttp://stackoverflow.com/usershttp://stackoverflow.com/tagshttp://stackoverflow.com/questionshttps://stackoverflow.com/users/login?ssrc=head&returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f20084892%2fandroid-edit-text-some-text-always-there-not-editablehttps://stackoverflow.com/users/signup?ssrc=head&returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f20084892%2fandroid-edit-text-some-text-always-there-not-editablehttp://stackoverflow.com/
  • 7/25/2019 Android Edit Text Some Text Always there not editable - Stack Overflow.pdf

    2/4

    2 Answers Order By Votes

    add a comment

    0The text of the EditText is "(hint)"

  • 7/25/2019 Android Edit Text Some Text Always there not editable - Stack Overflow.pdf

    3/4

    Your Answer

    1Maybe you can do this with addTextChangedListenerwith your EditText.But be carefull:

    This method is called to notify you that, somewhere within s, the text has beenchanged. It is legitimate to make further changes to s from this callback, butbe careful not to get yourself into an infinite loop, because any changes youmake will cause this method to be called again recursively. (You are not toldwhere the change took place because other afterTextChanged() methods may alreadyhave made other changes and invalidated the offsets

    (As you can see here: http://stackoverflow.com/a/10862398/2668136)

    You need to read these answers:

    1. Put constant text inside EditText which should be non-editable - Android2. Android java : Update same EditText in textChanged event3. Access edittext from textwatcher

    I suppose you can getLength()of the user's input and add your Stringat the end of your EditText.Hope this helpful.

    This could definitely work. You would merely set your the inputed text + " (non editable text)" with each event. Mark FreemanNov 20 '13 at 0:57

    Thanks for your help ! It worked for me . I used afterTextChanged. And it worked just like the way i want. Nouman Ahmad Nov 23 '13 at 14:07

    add a comment

    share improve this answer

    AnsweredNov 20 '13 at 0:45

    Fllo

    8,152

    3

    16

    47

    EditedNov 20 '13 at 0:51

    http://stackoverflow.com/posts/20085262/revisionshttp://stackoverflow.com/users/2668136/fllohttp://stackoverflow.com/users/2668136/fllohttp://stackoverflow.com/posts/20085262/edithttp://stackoverflow.com/a/20085262http://stackoverflow.com/users/3010984/nouman-ahmadhttp://stackoverflow.com/users/245634/mark-freemanhttp://stackoverflow.com/a/10862398/2668136http://stackoverflow.com/questions/9498155/android-java-update-same-edittext-in-textchanged-eventhttp://stackoverflow.com/a/14195571/2668136http://stackoverflow.com/a/10862398/2668136
  • 7/25/2019 Android Edit Text Some Text Always there not editable - Stack Overflow.pdf

    4/4

    Post Your Answer

    log in

    or

    Name

    Email

    By posting your answer, you agree to theprivacy policyand terms of service.

    meta chat tour help blog privacy policy legal contact us full site

    Download the Stack Exchange Android app

    2016 Stack Exchange, Inc

    https://play.google.com/store/apps/details?id=com.stackexchange.marvinhttp://stackoverflow.com/contacthttp://stackexchange.com/legalhttp://stackexchange.com/legal/privacy-policyhttp://blog.stackoverflow.com/http://stackoverflow.com/helphttp://stackoverflow.com/tourhttp://chat.stackoverflow.com/http://meta.stackoverflow.com/http://stackexchange.com/legal/terms-of-servicehttp://stackexchange.com/legal/privacy-policyhttp://stackoverflow.com/users/login?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f20084892%2fandroid-edit-text-some-text-always-there-not-editable