报的错误是
The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (MainActivity.mClick)
------------------------------------
The type MainActivity.mClick must implement the inherited abstract method DialogInterface.OnClickListener.onClick(DialogInterface, int)
代码是比这书上敲的 很简单
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt = (TextView) findViewById(R.id.shishi);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new mClick());
}
class mClick implements OnClickListener {
public void onClick(View v) {
MainActivity.this.setTitle("改变标题");
txt.setText(R.string.Str1);
}
}
1、是否引入了
import android.view.View;
import android.view.View.OnClickListener;
2、是否在strings.xml中增加了R.string.Str1
3、是否编译了
你这是什么错误也没说啊。。。。。。。。。。。。。。
类实现了onclicklistener { MClick
public void OnClick(视图){
主流。这settitle(“改变标题”);
txt。setText(R.string str1。);
}
你的onclickListener是不是引入的DialogInterface的工作空间
创建监听有三种方法 找最适合自己的一种比较好