問題描述
每當在 EditText 框中鍵入一個單詞時,我總是會在正在鍵入的單詞下方看到一個下劃線.但是當我在那個詞后面按一個空格時,我不再看到下劃線.
Whenever a word is typed in the EditText box, I always see an underline under the word being typed. But when I press a space after that word I no longer see the underline.
我的要求是在用戶鍵入消息時刪除該下劃線.
My reqirement is to remove that underline when the user is typing the message.
添加了屏幕截圖,我們看到 Smith 帶有下劃線.但我不希望這種情況發(fā)生.
Added is the screenshot and we see that Smith is underlined. But I don't want this to happen.
下面是我用于警報對話框的 xml.
Below is the xml that I use for the AlertDialog box.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/name_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/alert_dialog_name"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/username_edit"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:inputType="textPersonName"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
推薦答案
您不必使用任何邏輯來刪除下劃線——當您想使用該值時,只需調(diào)用 getText().toString() 即可.它不會包含特殊格式或任何內(nèi)容.
You don't have to use any logic to remove the underlines -- just call getText().toString() when you want to use the value. It won't include special formatting or anything.
這篇關于如何從 Android 中的 EditText 字段中刪除下劃線?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!