我想通过按钮从这个(KlikomaniaActivity)打开另一个活动(GameProcess),但是当我点击按钮时程序崩溃。我不是专业的android程序员,请说出我有什么错误:
packagecom.makeandroid.klikomania;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class KlikomaniaActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button Butstart = (Button)findViewById(R.id.butstart);
final Button Butrez = (Button)findViewById(R.id.butrez);
Butstart.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.makeandroid.klikomania.GameProcess");
// эапускаем деятельнсть
startService(intent);
}
});
}
}
在这里 GameProcess 活动:
public class GameProcess extends KlikomaniaActivity {
private static int rezult = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gameprocess);
final Button Butklik = (Button)findViewById(R.id.klik);
final TextView TextTime = (TextView)findViewById(R.id.texttime);
final TextView TextKolvo = (TextView)findViewById(R.id.kolvo);
Butklik.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
rezult=rezult+1;
TextKolvo.setText(rezult);
}
});
}
}