【发布时间】:2014-03-27 06:42:11
【问题描述】:
我的应用程序中有一个 EditText 和一个 Button。
当按钮被点击时,EditText中输入的文本被添加到ListView中。
如果 EditText 为空,我想禁用 Button。如何执行此操作?
这是我的按钮点击代码
ImageButton imb=(ImageButton)findViewById(R.id.btn_send);
imb.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
EditText et = (EditText)findViewById(R.id.EditText1);
String str = et.getText().toString();
web1.add(str);
Toast.makeText(ShoutSingleProgram.this, "You entered...."+str, Toast.LENGTH_SHORT).show();
adapter1.notifyDataSetChanged();
et.setText("");
}
});
}
我该怎么做?
【问题讨论】: