Okay i have a edit text box that takes user input. Every ti开发者_如何学JAVAme the user clicks the button i would like for the text that the user typed to be gone. As of now everytime the button is clicked the text remains in the edittext. I would like the text to be erased by default without having to create a instance of EditText everytime
Thanks guys if you can help!
Use setText()
:
mEditText.setText("");
after your setContentView:
final EditText yourEditText= (EditText)findViewById(R.id.yourIDEditText);
yourEditText.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
yourEditText.setText("");
}
});
With this, every time the user clicks all content is cleaned.
精彩评论