如何在它结束时创建的EditText交叉(X)按钮? [英] How to create EditText with cross(x) button at end of it?
本文介绍了如何在它结束时创建的EditText交叉(X)按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有像的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.
这篇关于如何在它结束时创建的EditText交叉(X)按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文