关于点击事件的有关问题
关于点击事件的问题求助。
这一行报错: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
求助。
------解决方案--------------------
new OnClickListener() 该为new View.OnClickListener()
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>
求助。
------解决方案--------------------
new OnClickListener() 该为new View.OnClickListener()