1. Are you ready for the Galaxy S20? Here is everything we know so far!

Read only Edit Text.

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

  1. manubharghav

    manubharghav Lurker
    Thread Starter

    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.

  2. cp1

    cp1 Android Enthusiast

    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 Newbie

  4. Rhyous

    Rhyous Lurker

    How do you do this in code?

  5. qasimValent

    qasimValent Newbie

    EditText txt = (EditText)findViewById(R.id.YOUREDITTEXTID);
  6. Sam Voss

    Sam Voss Android Enthusiast

    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


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

    miXer Android Enthusiast

    Use a TextView which is the non editable version of edittext.

Share This Page