package com.ActivityChange;import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.widget.Button;;public class Activity01 extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*捆绑ButtonListener至Button上*/
Button mybutton = (Button)findViewById(R.id.Btn01);
mybutton.setOnClickListener(new ButtonListener());
} class ButtonListener extends Activity implements OnClickListener
{ @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(Activity01.this, Activity02.class);
Activity01.this.startActivity(intent);
}
}
}
红色部分提示错误
The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (Activity01.ButtonListener)
是为什么呢
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.widget.Button;;public class Activity01 extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*捆绑ButtonListener至Button上*/
Button mybutton = (Button)findViewById(R.id.Btn01);
mybutton.setOnClickListener(new ButtonListener());
} class ButtonListener extends Activity implements OnClickListener
{ @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(Activity01.this, Activity02.class);
Activity01.this.startActivity(intent);
}
}
}
红色部分提示错误
The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (Activity01.ButtonListener)
是为什么呢
你实现的
import android.content.DialogInterface.OnClickListener要这个View.OnClickListene