Read only Edit Text.


Last Updated:

  1. manubharghav

    manubharghav New Member This Topic's Starter

    Joined:
    May 20, 2010
    Messages:
    1
    Likes Received:
    0
    is it possible to display the edittext widget to be readonly.

    for example.

    when we execute a sample program with edittext widget then is it possible for the user to only read the text that is only select it but not modify it anyway.

    please help.
     

    Advertisement
  2. cp1

    cp1 Well-Known Member

    Joined:
    Apr 30, 2010
    Messages:
    375
    Likes Received:
    35
    You could try setting inputtype to none -- that's the only option I see.

    You could also just use a textview instead.
     
  3. gorn

    gorn Well-Known Member

    Joined:
    Mar 22, 2010
    Messages:
    48
    Likes Received:
    11
    android:editable="false"
     
  4. Rhyous

    Rhyous New Member

    Joined:
    Sep 13, 2011
    Messages:
    2
    Likes Received:
    0
    How do you do this in code?

    Rhyous
     
  5. qasimValent

    qasimValent Active Member

    Joined:
    Jun 29, 2010
    Messages:
    39
    Likes Received:
    6
    EditText txt = (EditText)findViewById(R.id.YOUREDITTEXTID);
    txt.setEditable(false);
     
  6. Sam Voss

    Sam Voss Well-Known Member

    Joined:
    Jun 25, 2010
    Messages:
    367
    Likes Received:
    44
    while this works, if you would be able to do it from the xml, its going to be beneficial in the long run, cleaner code, etc
     
  7. Swizz

    Swizz Well-Known Member

    Joined:
    Nov 10, 2008
    Messages:
    730
    Likes Received:
    95
    android:editable="false"

    Note, having android:inputType seems to override the above snippet.
     
  8. miXer

    miXer Well-Known Member

    Joined:
    Aug 12, 2010
    Messages:
    313
    Likes Received:
    51
    Use a TextView which is the non editable version of edittext.
     

Share This Page

Loading...