如何重置的EditText一个动作完成之后? [英] How to reset EditText after an action has been completed?
本文介绍了如何重置的EditText一个动作完成之后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想我的EditText重置回按钮后,一个空的空间或暗示有会完成从现场的EditText输入活动pressed。
我的冒险与Android从而招手。
干杯。谢谢!!
// ************ -------------------发送短信--- ------------- ********* //
btnSendSMS =(按钮)findViewById(R.id.sms);
btnSendSMS.setOnClickListener(新View.OnClickListener(){ @覆盖
公共无效的onClick(视图v){
// TODO自动生成方法存根
sendSMS(。dispEd.getText()的toString(),msgEd.getText()的toString());
} 私人无效sendSMS(字符串phoneNumber的,弦乐味精){
// TODO自动生成方法存根
SmsManager短信= SmsManager.getDefault();
sms.sendTextMessage(phoneNumber的,空,味精,NULL,NULL);
}
});
}<的EditText
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID /编辑/><的EditText
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID /味精/>
解决方案
你应该尝试
editText.setText();
更新:尝试设置文本空
editText.setText(NULL);
I would like to reset my EditText back to an empty "space" or a "hint" after a button has pressed that would have completed an activity with input from the EditText field.
My adventure with android thus beckons.
Cheers. Thank you !!
//************-------------------SEND SMS----------------*********//
btnSendSMS = (Button)findViewById(R.id.sms);
btnSendSMS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
sendSMS(dispEd.getText().toString(),msgEd.getText().toString());
}
private void sendSMS(String phoneNumber, String msg) {
// TODO Auto-generated method stub
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, msg, null, null);
}
});
}
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/edit"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/msg"/>
解决方案
you should try
editText.setText("");
Update: Try setting text as null
editText.setText(null);
这篇关于如何重置的EditText一个动作完成之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文