Hi There. I am trying to build a game called 'spam' where you hit the button as much as possible in the given time. however, in the game class, it will run fine if I dont declare the actual spam button and the textviews that I want to change (score and time left).
I am using
But as soon as I try declare anything (the spam button or the time left text view or the score text view), when I try to start the activity (via the Intent), it says that
I am running Windows 7 Home Premium 64Bit, 8GB RAM, 1GB GDDR5 GTS 450 GeForce graphics card, Asus P8 motherboard, 2TB Samsung HDD, 500GB Samsung HDD, standard 16x optical drive, 5 fans, quad core i5 3.10GHz CPU.
This is my code for the class so far, and it crashes with the above error:
Thanks,
Josh
I am using
When I dont declare it ,ie: I DONT putfindViewById(R.id.theid);
, it runs fine - it is just static and wont do anything.spambutton = (Button) findViewById(R.id.gameSpamButton);
But as soon as I try declare anything (the spam button or the time left text view or the score text view), when I try to start the activity (via the Intent), it says that
I am using Eclipse Version: 3.7.1 Build id: M20110909-1335.the application test (com.example.test) has stopped unexpectedly. Please try again
I am running Windows 7 Home Premium 64Bit, 8GB RAM, 1GB GDDR5 GTS 450 GeForce graphics card, Asus P8 motherboard, 2TB Samsung HDD, 500GB Samsung HDD, standard 16x optical drive, 5 fans, quad core i5 3.10GHz CPU.
This is my code for the class so far, and it crashes with the above error:
However, if I comment out the declarations then it works fine, shown below:package com.example.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Game extends Activity{
Button spamme;
TextView timeleft, score;
public int points = 0;
public int finalscore = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.game);
//declaration of items
spamme = (Button) findViewById(R.id.gameSpamButton);
timeleft = (TextView) findViewById(R.id.gameTimeLeftTextView);
score = (Button) findViewById(R.id.gameScoreTextView);
//onClick events
//threads
}
}
Please help! it is driving me insane!package com.example.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Game extends Activity{
Button spamme;
TextView timeleft, score;
public int points = 0;
public int finalscore = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.game);
//declaration of items
//spamme = (Button) findViewById(R.id.gameSpamButton);
//timeleft = (TextView) findViewById(R.id.gameTimeLeftTextView);
//score = (Button) findViewById(R.id.gameScoreTextView);
//onClick events
//threads
}
}
Thanks,
Josh
