1. Download our Official Android App: Forums for Android!

Apps Read only Edit Text.

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

  1. manubharghav

    manubharghav Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    May 20, 2010

    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 Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    375
    Joined:
    Apr 30, 2010

    Apr 30, 2010
    375
    35
    53
    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 Member
    Rank:
    None
    Points:
    18
    Posts:
    48
    Joined:
    Mar 22, 2010

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

    Rhyous Lurker
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Sep 13, 2011

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

    Rhyous
     
  5. qasimValent

    qasimValent Member
    Rank:
    None
    Points:
    16
    Posts:
    39
    Joined:
    Jun 29, 2010

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

    Sam Voss Android Enthusiast
    Rank:
    None
    Points:
    43
    Posts:
    367
    Joined:
    Jun 25, 2010

    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 Android Enthusiast
    Rank:
    None
    Points:
    78
    Posts:
    730
    Joined:
    Nov 10, 2008

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

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

    miXer Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    313
    Joined:
    Aug 12, 2010

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

Share This Page

Loading...