关于点击事件的问题求助。

suce92 suce92 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
package com.suice.button;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class ButtonActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button b=(Button) findViewById(R.id.button);
b.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

}
});
}
}



这一行报错:b.setOnClickListener(new OnClickListener() {
内容:
Multiple markers at this line
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new
OnClickListener(){})
- OnClickListener cannot be resolved to a type

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点我啊" />

</LinearLayout>

求助。
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
suce92
Android 80,490 成员 91,375 内容