本文介紹了如何創建帶有交叉(x)按鈕的EditText?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
是否有像 EditText
這樣包含十字按鈕的小部件,或者是否有 EditText
的任何屬性可以自動創建它?我希望十字按鈕刪除寫在 EditText
中的任何文本.
Is there any widget like EditText
which contains a cross button, or is there any property for EditText
by which it is created automatically? I want the cross button to delete whatever text written in EditText
.
推薦答案
使用如下布局:
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:padding="5dp">
<EditText
android:id="@+id/calc_txt_Prise"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:layout_marginTop="20dp"
android:textSize="25dp"
android:textColor="@color/gray"
android:textStyle="bold"
android:hint="@string/calc_txt_Prise"
android:singleLine="true" />
<Button
android:id="@+id/calc_clear_txt_Prise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_gravity="right|center_vertical"
android:background="@drawable/delete" />
</FrameLayout>
您還可以使用按鈕的 id 并對其 onClickListener 方法執行您想要的任何操作.
You can also use the button's id and perform whatever action you want on its onClickListener method.
這篇關于如何創建帶有交叉(x)按鈕的EditText?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!