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)
是为什么呢
解决方案 »
- 分享Android入门学习资料
- android 图表控件问题
- 毕业设计求代做(无锡地区)
- 社交App 大屏手机 oom 求解决方案
- 阿里云搭建APP服务器
- 这是我见过的最奇葩的事,明明调用带五个参数的Matrix.translateM();可调试时却进到了带七个参数的Matrix.translateM(),有图有码
- 获取android设备上的图片问题
- java中为什么要用抽象类和接口?
- so文件加载异常,dlopen failed:has no loadable segments
- 安卓开发报错 Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUN
- Android新建项目时无法新选择Build Target 新手求各位大虾指点!
- 非常有挑战性:如何判断一个广播已经注册?如果注册了,则要解除它,重新注册
你实现的
import android.content.DialogInterface.OnClickListener要这个View.OnClickListene