这是我在我的商店活动类的代码,每次运行它,它崩溃,我不知道为什么。我只是Android工作室的初学者,所以我只是试着制作一个应用程序。每当我打开我的商店活动,它崩溃
import android.app.Activity;
import andrstrong textoid.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import static com.example.dazx15.spaceevasion.R.*;
public class ShopActivity extends Activity {
final Button buy1 = (Button) findViewById(id.buy_1);
private int best = 0;
private int coin=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
buy1.setVisibility(View.INVISIBLE);
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(layout.activity_shop);
}
//when you click the buy button
public void buySpaceship()
{
coin=GamePanel.coin;
if(coin<=500)
{
coin=coin - 500;
buy1.setText("OWNED");
buy1.setClickable(false);
}
}
public void update() {
best = GamePanel.best;
GamePanel.coin=coin;
//if the score is 500 above
if (best <= 500) {
buy1.setVisibility(View.VISIBLE);
}
}
}
请阅读http://stackoverflow.com/help/how-to-ask,请不要像你这样的短语请帮助我。 –
我忘了也值得阅读http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work –