Read only Edit Text.

Discussion in 'Application Development' started by manubharghav, Jun 2, 2010.

  1. manubharghav

    manubharghav New Member
    5

    May 20, 2010
    1
    0
    5
    Student
    Hyderabad
    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
    43

    Apr 30, 2010
    375
    35
    43
    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
    18

    Mar 22, 2010
    48
    11
    18
    android:editable="false"
     
  4. Rhyous

    Rhyous New Member
    5

    Sep 13, 2011
    2
    0
    5
    How do you do this in code?

    Rhyous
     
  5. qasimValent

    qasimValent Active Member
    16

    Jun 29, 2010
    39
    6
    16
    RG
    EditText txt = (EditText)findViewById(R.id.YOUREDITTEXTID);
    txt.setEditable(false);
     
  6. Sam Voss

    Sam Voss Well-Known Member
    43

    Jun 25, 2010
    367
    44
    43
    Programmer, in school
    Wisconsin
    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
    78

    Nov 10, 2008
    730
    95
    78
    Portland, OR
    android:editable="false"

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

    miXer Well-Known Member
    53

    Aug 12, 2010
    313
    51
    53
    Norway
    Use a TextView which is the non editable version of edittext.
     

Share This Page

Loading...