按钮 setonclicklistener 错误 [英] Button setonclicklistener error
本文介绍了按钮 setonclicklistener 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在遇到了 setOnClickListener
的问题.
I am having a problem right now with setOnClickListener
.
当我输入以下行时:
button.setOnClickListener(this);
然后运行应用程序,然后它不会运行并显示应用程序强制关闭"的消息.
And run the application then it does not run and shows a message that "Application closed forcefully".
您能帮我在 Android 2.2 中设置按钮 onclick 事件吗?
Could you please help me how I can set button onclick event in Android 2.2?
推荐答案
看看下面的代码是否适合你...
See if the code below works for you...
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
Toast.makeText(getApplicationContext(), "Hello World", Toast.LENGTH_LONG).show();
}
});
记得在最后加上});
.
这篇关于按钮 setonclicklistener 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文