In order to make your EditText to function like Textview(look & feel) follow the below steps.
Step 1:
Assign ID to your EditText object
EditText edtText = (EditText)findViewById(R.id.YourID);
Step 2:
Disable the edtText
edtText.setEnabled(false);
Step 3:
Disable cursor
edtText.setCursorVisible(false);
Step 4:
Set Key listner as null.
edtText.setKeyListener(null);
Step 5:
Make background Transparent
edtText.setBackgroundColor(Color.TRANSPARENT);
Now check your EditText
Step 1:
Assign ID to your EditText object
EditText edtText = (EditText)findViewById(R.id.YourID);
Step 2:
Disable the edtText
edtText.setEnabled(false);
Step 3:
Disable cursor
edtText.setCursorVisible(false);
Step 4:
Set Key listner as null.
edtText.setKeyListener(null);
Step 5:
Make background Transparent
edtText.setBackgroundColor(Color.TRANSPARENT);
Now check your EditText
Why not use styles?
ReplyDeleteandroid:background="@android:color/transparent"
android:editable="false"
android:cursorVisible="false"
In java you need to disable only KeyListener:
edtText.setKeyListener(null);
Dear Oleksii,
DeleteThats a good suggestion,
Thanks will update soon .
Excellent tips. Really useful stuff .Never had an idea about this, will look for more of such informative posts from your side... Good job...Keep it up
ReplyDeleteandroid app development perth | android app development sydney
IT WORKS FOR ME NICE POST
ReplyDelete