How to disable EditText in Android
up vote
65
down vote
favorite
How can I disable typing in an EditText
field in Android?
android android-edittext disabled-input
add a comment |
up vote
65
down vote
favorite
How can I disable typing in an EditText
field in Android?
android android-edittext disabled-input
1
Disable Keyboard on input in EditText ?
– Kartik Domadiya
May 4 '11 at 6:13
There are two editText fields.First is for entering email.if the email is valid then the second editText field is to be enabled.but the problem is while typing an invalid email and clicking on the next button on the soft keyboard it goes to the second text field and can enter data eventhough i've made edittext.setEnabled(false).i am using android 2.3.1
– aj10
May 4 '11 at 6:46
add a comment |
up vote
65
down vote
favorite
up vote
65
down vote
favorite
How can I disable typing in an EditText
field in Android?
android android-edittext disabled-input
How can I disable typing in an EditText
field in Android?
android android-edittext disabled-input
android android-edittext disabled-input
edited Nov 11 at 12:23
LAD
1,8141720
1,8141720
asked May 4 '11 at 6:06
aj10
3931410
3931410
1
Disable Keyboard on input in EditText ?
– Kartik Domadiya
May 4 '11 at 6:13
There are two editText fields.First is for entering email.if the email is valid then the second editText field is to be enabled.but the problem is while typing an invalid email and clicking on the next button on the soft keyboard it goes to the second text field and can enter data eventhough i've made edittext.setEnabled(false).i am using android 2.3.1
– aj10
May 4 '11 at 6:46
add a comment |
1
Disable Keyboard on input in EditText ?
– Kartik Domadiya
May 4 '11 at 6:13
There are two editText fields.First is for entering email.if the email is valid then the second editText field is to be enabled.but the problem is while typing an invalid email and clicking on the next button on the soft keyboard it goes to the second text field and can enter data eventhough i've made edittext.setEnabled(false).i am using android 2.3.1
– aj10
May 4 '11 at 6:46
1
1
Disable Keyboard on input in EditText ?
– Kartik Domadiya
May 4 '11 at 6:13
Disable Keyboard on input in EditText ?
– Kartik Domadiya
May 4 '11 at 6:13
There are two editText fields.First is for entering email.if the email is valid then the second editText field is to be enabled.but the problem is while typing an invalid email and clicking on the next button on the soft keyboard it goes to the second text field and can enter data eventhough i've made edittext.setEnabled(false).i am using android 2.3.1
– aj10
May 4 '11 at 6:46
There are two editText fields.First is for entering email.if the email is valid then the second editText field is to be enabled.but the problem is while typing an invalid email and clicking on the next button on the soft keyboard it goes to the second text field and can enter data eventhough i've made edittext.setEnabled(false).i am using android 2.3.1
– aj10
May 4 '11 at 6:46
add a comment |
14 Answers
14
active
oldest
votes
up vote
37
down vote
accepted
I think its a bug in android..It can be fixed by adding this patch :)
Check these links
question 1
and
question 2
Hope it will be useful.
1
Thanks .it works :)
– aj10
May 4 '11 at 7:03
94
For those who'd rather see the code right here rather than use a hyperlink:editText.setEnabled(false);
, in combination witheditText.setFocusable(false);
will achieve this.
– Mxyk
Jan 9 '12 at 15:00
6
The same works with XML:android:enabled="false"
andandroid:focusable="false"
. Thanks guys!
– jelies
Jan 21 '13 at 19:45
add a comment |
up vote
56
down vote
you can use EditText.setFocusable(false)
to disable editingEditText.setFocusableInTouchMode(true)
to enable editing;
2
It does not work for me
– ann
Jul 9 '14 at 9:15
4
This was my issue. I assumed that aftersetFocusable(false)
I could just flip setFocusable(true)... not the case. SettingsetFocusableInTouchMode(true)
did the trick for me.
– timgcarlson
Jul 17 '15 at 22:55
add a comment |
up vote
34
down vote
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
add a comment |
up vote
10
down vote
Assuming editText
is you EditText
object:
editText.setEnabled(false);
8
It doesn't work!
– meh
Oct 16 '12 at 13:38
add a comment |
up vote
8
down vote
Just set focusable property of your edittext to "false" and you are done.
<EditText
android:id="@+id/EditTextInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="right"
android:cursorVisible="true">
</EditText>
Below options doesn't work
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
add a comment |
up vote
8
down vote
You can try the following method :
private void disableEditText(EditText editText) {
editText.setFocusable(false);
editText.setEnabled(false);
editText.setCursorVisible(false);
editText.setKeyListener(null);
editText.setBackgroundColor(Color.TRANSPARENT);
}
Enabled EditText :
Disabled EditText :
It works for me and hope it helps you.
good answer but it can be improved by removing the line in which the background color is being change and add editText.setKeyListener(null);
– Syed Raza Mehdi
Aug 30 '16 at 9:45
add a comment |
up vote
4
down vote
Edittext edittext = (EditText)findViewById(R.id.edit);
edittext.setEnabled(false);
add a comment |
up vote
2
down vote
The below code disables the EditText in android
editText.setEnabled(false);
just set focusable property of your edittext to "false" and you are done. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <EditText android:id="@+id/EditTextInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="false" android:gravity="right" android:cursorVisible="true"> </EditText> <!-- end snippet -->
– ramit girdhar
Nov 25 '14 at 11:26
add a comment |
up vote
2
down vote
edittext.setFocusable(false);
edittext.setEnabled(false);
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
//removes on screen keyboard
add a comment |
up vote
1
down vote
To disable a edittext in android:
editText.setEnabled(false);
not working in some devices with version < 2.3.
– Ketan Ahir
Dec 10 '13 at 9:10
add a comment |
up vote
1
down vote
You can write edittext.setInputType(0)
if you want to show the edittext but not input any values
add a comment |
up vote
0
down vote
Write this in parent:
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
Example:
<RelativeLayout
android:id="@+id/menu_2_zawezanie_rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/menu_2_horizontalScrollView"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:background="@drawable/rame">
<EditText
android:id="@+id/menu2_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/menu2_ibtn"
android:gravity="center"
android:hint="@string/filtruj" >
</EditText>
<ImageButton
android:id="@+id/menu2_ibtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@null"
android:src="@drawable/selector_btn" />
add a comment |
up vote
0
down vote
According to me...if you have already declared the edittext
in the XML file and set the property in the XML file "android:enabled=false"
and disable at runtime to it at that time in java file adding only 2 or 3 lines
- First create the object
- Declare EditText et1;
Get by id
et1 = (EditText) FindViewById(R.id.edittext1);
et1.setEnabled(false);
You can do enable or disable to every control at run time by java file and design time by XML file.
add a comment |
up vote
0
down vote
Enable:
private void enableEditText() {
mEditText.setFocusableInTouchMode(true);
mEditText.setFocusable(true);
mEditText.setEnabled(true);
}
Disable:
private void disableEditText() {
mEditText.setEnabled(false);
mEditText.setFocusable(false);
mEditText.setFocusableInTouchMode(false);
}
add a comment |
14 Answers
14
active
oldest
votes
14 Answers
14
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
37
down vote
accepted
I think its a bug in android..It can be fixed by adding this patch :)
Check these links
question 1
and
question 2
Hope it will be useful.
1
Thanks .it works :)
– aj10
May 4 '11 at 7:03
94
For those who'd rather see the code right here rather than use a hyperlink:editText.setEnabled(false);
, in combination witheditText.setFocusable(false);
will achieve this.
– Mxyk
Jan 9 '12 at 15:00
6
The same works with XML:android:enabled="false"
andandroid:focusable="false"
. Thanks guys!
– jelies
Jan 21 '13 at 19:45
add a comment |
up vote
37
down vote
accepted
I think its a bug in android..It can be fixed by adding this patch :)
Check these links
question 1
and
question 2
Hope it will be useful.
1
Thanks .it works :)
– aj10
May 4 '11 at 7:03
94
For those who'd rather see the code right here rather than use a hyperlink:editText.setEnabled(false);
, in combination witheditText.setFocusable(false);
will achieve this.
– Mxyk
Jan 9 '12 at 15:00
6
The same works with XML:android:enabled="false"
andandroid:focusable="false"
. Thanks guys!
– jelies
Jan 21 '13 at 19:45
add a comment |
up vote
37
down vote
accepted
up vote
37
down vote
accepted
I think its a bug in android..It can be fixed by adding this patch :)
Check these links
question 1
and
question 2
Hope it will be useful.
I think its a bug in android..It can be fixed by adding this patch :)
Check these links
question 1
and
question 2
Hope it will be useful.
edited Jul 9 '14 at 9:22
ann
5881919
5881919
answered May 4 '11 at 7:01
Midhun
41233
41233
1
Thanks .it works :)
– aj10
May 4 '11 at 7:03
94
For those who'd rather see the code right here rather than use a hyperlink:editText.setEnabled(false);
, in combination witheditText.setFocusable(false);
will achieve this.
– Mxyk
Jan 9 '12 at 15:00
6
The same works with XML:android:enabled="false"
andandroid:focusable="false"
. Thanks guys!
– jelies
Jan 21 '13 at 19:45
add a comment |
1
Thanks .it works :)
– aj10
May 4 '11 at 7:03
94
For those who'd rather see the code right here rather than use a hyperlink:editText.setEnabled(false);
, in combination witheditText.setFocusable(false);
will achieve this.
– Mxyk
Jan 9 '12 at 15:00
6
The same works with XML:android:enabled="false"
andandroid:focusable="false"
. Thanks guys!
– jelies
Jan 21 '13 at 19:45
1
1
Thanks .it works :)
– aj10
May 4 '11 at 7:03
Thanks .it works :)
– aj10
May 4 '11 at 7:03
94
94
For those who'd rather see the code right here rather than use a hyperlink:
editText.setEnabled(false);
, in combination with editText.setFocusable(false);
will achieve this.– Mxyk
Jan 9 '12 at 15:00
For those who'd rather see the code right here rather than use a hyperlink:
editText.setEnabled(false);
, in combination with editText.setFocusable(false);
will achieve this.– Mxyk
Jan 9 '12 at 15:00
6
6
The same works with XML:
android:enabled="false"
and android:focusable="false"
. Thanks guys!– jelies
Jan 21 '13 at 19:45
The same works with XML:
android:enabled="false"
and android:focusable="false"
. Thanks guys!– jelies
Jan 21 '13 at 19:45
add a comment |
up vote
56
down vote
you can use EditText.setFocusable(false)
to disable editingEditText.setFocusableInTouchMode(true)
to enable editing;
2
It does not work for me
– ann
Jul 9 '14 at 9:15
4
This was my issue. I assumed that aftersetFocusable(false)
I could just flip setFocusable(true)... not the case. SettingsetFocusableInTouchMode(true)
did the trick for me.
– timgcarlson
Jul 17 '15 at 22:55
add a comment |
up vote
56
down vote
you can use EditText.setFocusable(false)
to disable editingEditText.setFocusableInTouchMode(true)
to enable editing;
2
It does not work for me
– ann
Jul 9 '14 at 9:15
4
This was my issue. I assumed that aftersetFocusable(false)
I could just flip setFocusable(true)... not the case. SettingsetFocusableInTouchMode(true)
did the trick for me.
– timgcarlson
Jul 17 '15 at 22:55
add a comment |
up vote
56
down vote
up vote
56
down vote
you can use EditText.setFocusable(false)
to disable editingEditText.setFocusableInTouchMode(true)
to enable editing;
you can use EditText.setFocusable(false)
to disable editingEditText.setFocusableInTouchMode(true)
to enable editing;
edited Feb 6 '12 at 7:57
Aliaksei Kliuchnikau
11.7k34865
11.7k34865
answered Feb 6 '12 at 7:24
chaitanya
1,28111310
1,28111310
2
It does not work for me
– ann
Jul 9 '14 at 9:15
4
This was my issue. I assumed that aftersetFocusable(false)
I could just flip setFocusable(true)... not the case. SettingsetFocusableInTouchMode(true)
did the trick for me.
– timgcarlson
Jul 17 '15 at 22:55
add a comment |
2
It does not work for me
– ann
Jul 9 '14 at 9:15
4
This was my issue. I assumed that aftersetFocusable(false)
I could just flip setFocusable(true)... not the case. SettingsetFocusableInTouchMode(true)
did the trick for me.
– timgcarlson
Jul 17 '15 at 22:55
2
2
It does not work for me
– ann
Jul 9 '14 at 9:15
It does not work for me
– ann
Jul 9 '14 at 9:15
4
4
This was my issue. I assumed that after
setFocusable(false)
I could just flip setFocusable(true)... not the case. Setting setFocusableInTouchMode(true)
did the trick for me.– timgcarlson
Jul 17 '15 at 22:55
This was my issue. I assumed that after
setFocusable(false)
I could just flip setFocusable(true)... not the case. Setting setFocusableInTouchMode(true)
did the trick for me.– timgcarlson
Jul 17 '15 at 22:55
add a comment |
up vote
34
down vote
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
add a comment |
up vote
34
down vote
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
add a comment |
up vote
34
down vote
up vote
34
down vote
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
answered May 4 '11 at 6:13
Gabriel Negut
10.8k32842
10.8k32842
add a comment |
add a comment |
up vote
10
down vote
Assuming editText
is you EditText
object:
editText.setEnabled(false);
8
It doesn't work!
– meh
Oct 16 '12 at 13:38
add a comment |
up vote
10
down vote
Assuming editText
is you EditText
object:
editText.setEnabled(false);
8
It doesn't work!
– meh
Oct 16 '12 at 13:38
add a comment |
up vote
10
down vote
up vote
10
down vote
Assuming editText
is you EditText
object:
editText.setEnabled(false);
Assuming editText
is you EditText
object:
editText.setEnabled(false);
answered May 4 '11 at 6:12
MByD
116k22223249
116k22223249
8
It doesn't work!
– meh
Oct 16 '12 at 13:38
add a comment |
8
It doesn't work!
– meh
Oct 16 '12 at 13:38
8
8
It doesn't work!
– meh
Oct 16 '12 at 13:38
It doesn't work!
– meh
Oct 16 '12 at 13:38
add a comment |
up vote
8
down vote
Just set focusable property of your edittext to "false" and you are done.
<EditText
android:id="@+id/EditTextInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="right"
android:cursorVisible="true">
</EditText>
Below options doesn't work
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
add a comment |
up vote
8
down vote
Just set focusable property of your edittext to "false" and you are done.
<EditText
android:id="@+id/EditTextInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="right"
android:cursorVisible="true">
</EditText>
Below options doesn't work
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
add a comment |
up vote
8
down vote
up vote
8
down vote
Just set focusable property of your edittext to "false" and you are done.
<EditText
android:id="@+id/EditTextInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="right"
android:cursorVisible="true">
</EditText>
Below options doesn't work
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
Just set focusable property of your edittext to "false" and you are done.
<EditText
android:id="@+id/EditTextInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="right"
android:cursorVisible="true">
</EditText>
Below options doesn't work
In code:
editText.setEnabled(false);
Or, in XML:
android:editable="false"
edited Nov 27 '14 at 5:49
answered Nov 25 '14 at 11:31
ramit girdhar
1,3581622
1,3581622
add a comment |
add a comment |
up vote
8
down vote
You can try the following method :
private void disableEditText(EditText editText) {
editText.setFocusable(false);
editText.setEnabled(false);
editText.setCursorVisible(false);
editText.setKeyListener(null);
editText.setBackgroundColor(Color.TRANSPARENT);
}
Enabled EditText :
Disabled EditText :
It works for me and hope it helps you.
good answer but it can be improved by removing the line in which the background color is being change and add editText.setKeyListener(null);
– Syed Raza Mehdi
Aug 30 '16 at 9:45
add a comment |
up vote
8
down vote
You can try the following method :
private void disableEditText(EditText editText) {
editText.setFocusable(false);
editText.setEnabled(false);
editText.setCursorVisible(false);
editText.setKeyListener(null);
editText.setBackgroundColor(Color.TRANSPARENT);
}
Enabled EditText :
Disabled EditText :
It works for me and hope it helps you.
good answer but it can be improved by removing the line in which the background color is being change and add editText.setKeyListener(null);
– Syed Raza Mehdi
Aug 30 '16 at 9:45
add a comment |
up vote
8
down vote
up vote
8
down vote
You can try the following method :
private void disableEditText(EditText editText) {
editText.setFocusable(false);
editText.setEnabled(false);
editText.setCursorVisible(false);
editText.setKeyListener(null);
editText.setBackgroundColor(Color.TRANSPARENT);
}
Enabled EditText :
Disabled EditText :
It works for me and hope it helps you.
You can try the following method :
private void disableEditText(EditText editText) {
editText.setFocusable(false);
editText.setEnabled(false);
editText.setCursorVisible(false);
editText.setKeyListener(null);
editText.setBackgroundColor(Color.TRANSPARENT);
}
Enabled EditText :
Disabled EditText :
It works for me and hope it helps you.
edited Apr 3 '15 at 14:51
answered Apr 3 '15 at 14:19
Maksym Kalin
1,1531315
1,1531315
good answer but it can be improved by removing the line in which the background color is being change and add editText.setKeyListener(null);
– Syed Raza Mehdi
Aug 30 '16 at 9:45
add a comment |
good answer but it can be improved by removing the line in which the background color is being change and add editText.setKeyListener(null);
– Syed Raza Mehdi
Aug 30 '16 at 9:45
good answer but it can be improved by removing the line in which the background color is being change and add editText.setKeyListener(null);
– Syed Raza Mehdi
Aug 30 '16 at 9:45
good answer but it can be improved by removing the line in which the background color is being change and add editText.setKeyListener(null);
– Syed Raza Mehdi
Aug 30 '16 at 9:45
add a comment |
up vote
4
down vote
Edittext edittext = (EditText)findViewById(R.id.edit);
edittext.setEnabled(false);
add a comment |
up vote
4
down vote
Edittext edittext = (EditText)findViewById(R.id.edit);
edittext.setEnabled(false);
add a comment |
up vote
4
down vote
up vote
4
down vote
Edittext edittext = (EditText)findViewById(R.id.edit);
edittext.setEnabled(false);
Edittext edittext = (EditText)findViewById(R.id.edit);
edittext.setEnabled(false);
answered Apr 10 '17 at 11:29
saigopi
3,1842221
3,1842221
add a comment |
add a comment |
up vote
2
down vote
The below code disables the EditText in android
editText.setEnabled(false);
just set focusable property of your edittext to "false" and you are done. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <EditText android:id="@+id/EditTextInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="false" android:gravity="right" android:cursorVisible="true"> </EditText> <!-- end snippet -->
– ramit girdhar
Nov 25 '14 at 11:26
add a comment |
up vote
2
down vote
The below code disables the EditText in android
editText.setEnabled(false);
just set focusable property of your edittext to "false" and you are done. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <EditText android:id="@+id/EditTextInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="false" android:gravity="right" android:cursorVisible="true"> </EditText> <!-- end snippet -->
– ramit girdhar
Nov 25 '14 at 11:26
add a comment |
up vote
2
down vote
up vote
2
down vote
The below code disables the EditText in android
editText.setEnabled(false);
The below code disables the EditText in android
editText.setEnabled(false);
edited May 4 '11 at 21:13
GSerg
58.6k14100217
58.6k14100217
answered May 4 '11 at 6:38
uday
6303915
6303915
just set focusable property of your edittext to "false" and you are done. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <EditText android:id="@+id/EditTextInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="false" android:gravity="right" android:cursorVisible="true"> </EditText> <!-- end snippet -->
– ramit girdhar
Nov 25 '14 at 11:26
add a comment |
just set focusable property of your edittext to "false" and you are done. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <EditText android:id="@+id/EditTextInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="false" android:gravity="right" android:cursorVisible="true"> </EditText> <!-- end snippet -->
– ramit girdhar
Nov 25 '14 at 11:26
just set focusable property of your edittext to "false" and you are done. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <EditText android:id="@+id/EditTextInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="false" android:gravity="right" android:cursorVisible="true"> </EditText> <!-- end snippet -->
– ramit girdhar
Nov 25 '14 at 11:26
just set focusable property of your edittext to "false" and you are done. <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <EditText android:id="@+id/EditTextInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="false" android:gravity="right" android:cursorVisible="true"> </EditText> <!-- end snippet -->
– ramit girdhar
Nov 25 '14 at 11:26
add a comment |
up vote
2
down vote
edittext.setFocusable(false);
edittext.setEnabled(false);
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
//removes on screen keyboard
add a comment |
up vote
2
down vote
edittext.setFocusable(false);
edittext.setEnabled(false);
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
//removes on screen keyboard
add a comment |
up vote
2
down vote
up vote
2
down vote
edittext.setFocusable(false);
edittext.setEnabled(false);
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
//removes on screen keyboard
edittext.setFocusable(false);
edittext.setEnabled(false);
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
//removes on screen keyboard
edited Apr 1 '12 at 23:17
dldnh
8,47432747
8,47432747
answered Apr 1 '12 at 21:39
Kumar Sukhani
32827
32827
add a comment |
add a comment |
up vote
1
down vote
To disable a edittext in android:
editText.setEnabled(false);
not working in some devices with version < 2.3.
– Ketan Ahir
Dec 10 '13 at 9:10
add a comment |
up vote
1
down vote
To disable a edittext in android:
editText.setEnabled(false);
not working in some devices with version < 2.3.
– Ketan Ahir
Dec 10 '13 at 9:10
add a comment |
up vote
1
down vote
up vote
1
down vote
To disable a edittext in android:
editText.setEnabled(false);
To disable a edittext in android:
editText.setEnabled(false);
edited May 4 '11 at 21:13
GSerg
58.6k14100217
58.6k14100217
answered May 4 '11 at 6:16
Vineet
812
812
not working in some devices with version < 2.3.
– Ketan Ahir
Dec 10 '13 at 9:10
add a comment |
not working in some devices with version < 2.3.
– Ketan Ahir
Dec 10 '13 at 9:10
not working in some devices with version < 2.3.
– Ketan Ahir
Dec 10 '13 at 9:10
not working in some devices with version < 2.3.
– Ketan Ahir
Dec 10 '13 at 9:10
add a comment |
up vote
1
down vote
You can write edittext.setInputType(0)
if you want to show the edittext but not input any values
add a comment |
up vote
1
down vote
You can write edittext.setInputType(0)
if you want to show the edittext but not input any values
add a comment |
up vote
1
down vote
up vote
1
down vote
You can write edittext.setInputType(0)
if you want to show the edittext but not input any values
You can write edittext.setInputType(0)
if you want to show the edittext but not input any values
edited May 4 '11 at 21:14
GSerg
58.6k14100217
58.6k14100217
answered May 4 '11 at 6:35
Jaydeep Khamar
5,49032630
5,49032630
add a comment |
add a comment |
up vote
0
down vote
Write this in parent:
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
Example:
<RelativeLayout
android:id="@+id/menu_2_zawezanie_rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/menu_2_horizontalScrollView"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:background="@drawable/rame">
<EditText
android:id="@+id/menu2_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/menu2_ibtn"
android:gravity="center"
android:hint="@string/filtruj" >
</EditText>
<ImageButton
android:id="@+id/menu2_ibtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@null"
android:src="@drawable/selector_btn" />
add a comment |
up vote
0
down vote
Write this in parent:
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
Example:
<RelativeLayout
android:id="@+id/menu_2_zawezanie_rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/menu_2_horizontalScrollView"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:background="@drawable/rame">
<EditText
android:id="@+id/menu2_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/menu2_ibtn"
android:gravity="center"
android:hint="@string/filtruj" >
</EditText>
<ImageButton
android:id="@+id/menu2_ibtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@null"
android:src="@drawable/selector_btn" />
add a comment |
up vote
0
down vote
up vote
0
down vote
Write this in parent:
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
Example:
<RelativeLayout
android:id="@+id/menu_2_zawezanie_rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/menu_2_horizontalScrollView"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:background="@drawable/rame">
<EditText
android:id="@+id/menu2_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/menu2_ibtn"
android:gravity="center"
android:hint="@string/filtruj" >
</EditText>
<ImageButton
android:id="@+id/menu2_ibtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@null"
android:src="@drawable/selector_btn" />
Write this in parent:
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
Example:
<RelativeLayout
android:id="@+id/menu_2_zawezanie_rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/menu_2_horizontalScrollView"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:background="@drawable/rame">
<EditText
android:id="@+id/menu2_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/menu2_ibtn"
android:gravity="center"
android:hint="@string/filtruj" >
</EditText>
<ImageButton
android:id="@+id/menu2_ibtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@null"
android:src="@drawable/selector_btn" />
edited Dec 2 '13 at 5:55
answered Dec 2 '13 at 3:30
Gimer
135
135
add a comment |
add a comment |
up vote
0
down vote
According to me...if you have already declared the edittext
in the XML file and set the property in the XML file "android:enabled=false"
and disable at runtime to it at that time in java file adding only 2 or 3 lines
- First create the object
- Declare EditText et1;
Get by id
et1 = (EditText) FindViewById(R.id.edittext1);
et1.setEnabled(false);
You can do enable or disable to every control at run time by java file and design time by XML file.
add a comment |
up vote
0
down vote
According to me...if you have already declared the edittext
in the XML file and set the property in the XML file "android:enabled=false"
and disable at runtime to it at that time in java file adding only 2 or 3 lines
- First create the object
- Declare EditText et1;
Get by id
et1 = (EditText) FindViewById(R.id.edittext1);
et1.setEnabled(false);
You can do enable or disable to every control at run time by java file and design time by XML file.
add a comment |
up vote
0
down vote
up vote
0
down vote
According to me...if you have already declared the edittext
in the XML file and set the property in the XML file "android:enabled=false"
and disable at runtime to it at that time in java file adding only 2 or 3 lines
- First create the object
- Declare EditText et1;
Get by id
et1 = (EditText) FindViewById(R.id.edittext1);
et1.setEnabled(false);
You can do enable or disable to every control at run time by java file and design time by XML file.
According to me...if you have already declared the edittext
in the XML file and set the property in the XML file "android:enabled=false"
and disable at runtime to it at that time in java file adding only 2 or 3 lines
- First create the object
- Declare EditText et1;
Get by id
et1 = (EditText) FindViewById(R.id.edittext1);
et1.setEnabled(false);
You can do enable or disable to every control at run time by java file and design time by XML file.
edited Jul 9 '14 at 9:30
ann
5881919
5881919
answered Feb 23 '14 at 18:52
Nimisha Patel
112
112
add a comment |
add a comment |
up vote
0
down vote
Enable:
private void enableEditText() {
mEditText.setFocusableInTouchMode(true);
mEditText.setFocusable(true);
mEditText.setEnabled(true);
}
Disable:
private void disableEditText() {
mEditText.setEnabled(false);
mEditText.setFocusable(false);
mEditText.setFocusableInTouchMode(false);
}
add a comment |
up vote
0
down vote
Enable:
private void enableEditText() {
mEditText.setFocusableInTouchMode(true);
mEditText.setFocusable(true);
mEditText.setEnabled(true);
}
Disable:
private void disableEditText() {
mEditText.setEnabled(false);
mEditText.setFocusable(false);
mEditText.setFocusableInTouchMode(false);
}
add a comment |
up vote
0
down vote
up vote
0
down vote
Enable:
private void enableEditText() {
mEditText.setFocusableInTouchMode(true);
mEditText.setFocusable(true);
mEditText.setEnabled(true);
}
Disable:
private void disableEditText() {
mEditText.setEnabled(false);
mEditText.setFocusable(false);
mEditText.setFocusableInTouchMode(false);
}
Enable:
private void enableEditText() {
mEditText.setFocusableInTouchMode(true);
mEditText.setFocusable(true);
mEditText.setEnabled(true);
}
Disable:
private void disableEditText() {
mEditText.setEnabled(false);
mEditText.setFocusable(false);
mEditText.setFocusableInTouchMode(false);
}
answered Oct 10 at 10:21
Danylo Volokh
2,13212030
2,13212030
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f5879250%2fhow-to-disable-edittext-in-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Disable Keyboard on input in EditText ?
– Kartik Domadiya
May 4 '11 at 6:13
There are two editText fields.First is for entering email.if the email is valid then the second editText field is to be enabled.but the problem is while typing an invalid email and clicking on the next button on the soft keyboard it goes to the second text field and can enter data eventhough i've made edittext.setEnabled(false).i am using android 2.3.1
– aj10
May 4 '11 at 6:46