我是android編程中的新手。我看到很多方法可以做到的事件處理,但是當我試圖通過調用處理程序類,它給出處理類名稱錯誤做到這一點:java android處理程序調用
package com.example.test;
import android.app.Activity;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//attach an instance of HandleClick to the Button
findViewById(R.id.button1).setOnClickListener(new HandleClick());
}
private class HandleClick implements OnClickListener{
public void onClick(View arg0) {
Button btn = (Button)arg0; //cast view to a button
// get a reference to the TextView
TextView tv = (TextView) findViewById(R.id.textview1);
// update the TextView text
tv.setText("You pressed " + btn.getText());
}
}
}
"HandleClick"
錯誤來對這個好說類應該是抽象的類型?
我不明白爲什麼它給這個錯誤可以幫助我嗎?