-5

我的代码是:

Button button1=(Button)findViewById(R.id.button2);

OnClickListener onclick1 = new OnClickListener() {
        @Override
        public void onClick(View v) {
            et.setText("");
        }
    };
    button1.setOnClickListener(onclick1);
4

2 回答 2

0

更具体地说明您的问题。但是,如果您只想清除EditTexton 按钮单击,那么您可以这样做:

Button button1=(Button)findViewById(R.id.button2);

 button1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

et.setText("");


            }
        });
于 2012-05-14T06:00:31.210 回答
0
button2.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        spinner.setSelection(0); //if the field is spinner
        editText.setText("");  //if the field is EditText
    }
});
于 2012-05-14T06:01:44.217 回答