Disabling of EditText in Android
I believe the correct would be to set android:editable="false"
.
And if you wonder why my link point to the attributes of TextView
, you the answer is because EditText
inherits from TextView
:
EditText is a thin veneer over
TextView that configures itself to be
editable.
Update:
As mentioned in the comments below, editable
is deprecated (since API level 3). You should instead be using inputType
(with the value none
).
How to disable EditText in Android
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.
EditText: how to enable/disable input?
I finally found a solution. It's a matter of calling
setFocusableInTouchMode(boolean)
setFocusable(boolean)
when the EditText
is first created, so it can intercept the clicks. Then one can set those flags back again to make the EditText
editable, request the focus, and manually show/hide the soft keyboard with InputMethodManager
methods
How to make an EditText uneditable/disabled
This works fine; 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>
Enable/Disable editText with a Switch in Android Studio
You can set the OnCheckedChangeListener
of the switch.
switchGaranzia.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
//enable
} else {
//disable
}
}
});
Related Topics
Programmatically Change the Value of a Color Resource Obtained from API Response
Reading Text File from Server on Android
What Does It Mean "No Launcher Activity Found!"
Android Studio Error Installing Gradle
Broadcastreceiver When Wifi or 3G Network State Changed
Force Overflow Menu in Actionbarsherlock
How to Implement Getfilter() with Custom Adapter That Extends Baseadapter
Get Path of Image from Action_Image_Capture Intent
Unicode Characters Not Displayed in Textview.Settext
Gson Noclassdeffounderror After Adt and Sdk Tools Update to V17
How to Send Http Post Request and Receive Response
How to Know the Map Is Ready to Get Used When Using the Supportmapfragment
Detect the Status of Two Sim Cards in a Dual-Sim Android Phone
Android Toast Message Is Not Showing
Android Gettext from Edittext Field
Android Calendarview for Showing Events
How to Catch Sigsegv (Segmentation Fault) and Get a Stack Trace Under Jni on Android