I am trying to create an EditText which toggles its state between read only and write mode. My XML is as below:
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textArea"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="4"
android:inputType="textMultiLine">
</EditText>
In my code i do the following :
textArea = (EditText) convertView.findViewById(com.pravaa.mobile.R.id.textArea);
//isEditable decides if the EditText is editable or not
if(!isEditable){
textArea.setInputType(InputType.TYPE_NULL);
}
//the view is added to a linear layout.
addView(textArea);
My issue is that the text does not get wrapped. Am i missing out on something? Kindly help me with this. I have also attached an image of my output.
The text set in the view is "12345678901234567 90123456789012345678901234567890 Nationwide Campaign New"
New! Save questions or answers and organize your favorite content. Learn more.
TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.
In your xml code set focusable="false" , android:clickable="false" and android:cursorVisible="false" and this will make your EditText treat like non editable.
A EditText is an overlay over TextView that configures itself to be editable. It is the predefined subclass of TextView that includes rich editing capabilities.
I was able to solve this issue by removing
android:inputType="textMultiLine"
To achieve the non-editable feature I used
setFocusable(false);
I guess that by calling this ...
textArea.setInputType(InputType.TYPE_NULL);
you override the flag InputType.TYPE_TEXT_FLAG_MULTI_LINE. Try calling this instead...
textArea.setInputType(InputType.TYPE_NULL|InputType.TYPE_TEXT_FLAG_MULTI_LINE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With