1

Here is my code...

            package com.bmc;


            public class Details extends Activity 
            {

                public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.details);

                    EditText desc,sol;

            /*
                Some code here...........


             */     desc=(EditText) findViewById(R.id.editText_desc1);
                    sol=(EditText) findViewById(R.id.editText_sol);
                   desc.setEnabled(false);
                   sol.setEnabled(false);
                   sol.setClickable(false);
                   desc.setClickable(false);

                }

            }

Here sol becomes write protected but desc does not. Does anyone have a solution? Thanks.

prolink007
  • 33,872
  • 24
  • 117
  • 185
Bhushan Baviskar
  • 53
  • 1
  • 2
  • 8
  • The "Some code here" bit is pretty major to miss out. We have no idea what you're doing to initialise these, where you're putting them, what layout types they are in, anything. – Zulaxia Dec 27 '11 at 16:45

3 Answers3

2

Try this, the best way to do it from code. It will also restrict your keyboard to pop up for typing.

Actually it disabled you key stroke on that edittext.

EditText desc = (EditText)findViewById(R.id.editText_desc1);
desc.setKeyListener(null);
EditText sol = (EditText)findViewById(R.id.editText_sol);
sol.setKeyListener(null);
dakshbhatt21
  • 3,558
  • 3
  • 31
  • 40
2

Try the following

android:editable="false"

in the edittext.

prolink007
  • 33,872
  • 24
  • 117
  • 185
Tony
  • 10,088
  • 20
  • 85
  • 139
0

Try this:

desc.setEnabled(false);
desc.setClickable(false);
desc.setFocusable(false);
sol.setEnabled(false);
sol.setClickable(false);
sol.setFocusable(false);

Let me know how it goes.

Also, more help here if needed.

Community
  • 1
  • 1
prolink007
  • 33,872
  • 24
  • 117
  • 185