按钮setonclicklistener错误 [英] Button setonclicklistener error

查看:104
本文介绍了按钮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?

推荐答案

您可以试试下面的code

You can try the below code

button.setOnClickListener(new OnClickListener() {           

  @Override
  public void onClick(View v) 
  {
      Toast.makeText(this, "Hello World", Toast.LENGTH_LONG).show();
  }    
}

这篇关于按钮setonclicklistener错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆