我正在尝试创建一个可在只读模式和写入模式之间切换的EditText。
我的XML如下所示:
<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>
我的代码是这样的:
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);
我的问题是文本没有换行。我是否遗漏了什么?请帮助我解决这个问题。我还附上了我的输出图像。
该视图中设置的文本为“12345678901234567 90123456789012345678901234567890 Nationwide Campaign New”。
![EditText does not exapnd in height](https://istack.dev59.com/wswp2.webp)
![The text does not wrap](https://istack.dev59.com/U5Aao.webp)
setEnabled(false);
呢? - Bugs Happen