報的錯誤是
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、是否編譯了