This is my first post on the site, and I'll try to be just as specific as the tips requested. I'm using eclipse Helios, with the ADT 10.0.1
I've been working on an Android application which is supposed to be a general guide of Starcraft II. Pretty basic stuff, it's for a programming class. It's supposed to have an intro background with a continue button, linking to the main menu.
The main menu consists a few buttons that should all link to different layouts created. When I start my application in an emulator (I tried level 12, 9 etc.) the first button links to the menu, but the buttons on the menu fail to link. I have no syntax errors in my code, however it does show the whole yellow underline for all the buttons except the first one. I've fiddled with the basic syntax a bit on and off to get it to not display any red or yellow underlines, and it didn't get me anywhere either. When I removed the last button from the code, which is a back button from the layouts, linking back to the front menu, the buttons on the menu instead started linking to the last button's link, by which I mean the last one in the code. So I thought it might be skipping all of the other listeners and just using the one for the last button in the code, or something like that. Bear in mind I'm not very good at programming yet.
Here's the basic look of the code.
package lol.lol;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class ofk extends Activity {
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle button1) {
super.onCreate(button1);
setContentView(R.layout.intro);
Button button = (Button) findViewById(R.id.continuebutton);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.frontmenu);
}
});
final Button button2 = (Button) findViewById(R.id.aboutapp);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.aboutsc2g);
}
});
final Button button3 = (Button) findViewById(R.id.aboutsc);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.aboutsc2);
// Perform action on click
}
});
final Button button4 = (Button) findViewById(R.id.micro);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.micro);
// Perform action on click
}
});
final Button button5 = (Button) findViewById(R.id.macro);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.macro);
// Perform action on click
}
});
final Button button6 = (Button) findViewById(R.id.mechanics);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.mechanics);
// Perform action on click
}
});
final Button button7 = (Button) findViewById(R.id.zergbasics);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.zergbasics);
// Perform action on click
}
});
final Button button8 = (Button) findViewById(R.id.terranbasics);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.terranbasics);
// Perform action on click
}
});
final Button button9 = (Button) findViewById(R.id.protossbasics);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.protossbasics);
// Perform action on click
}
});
final Button button10 = (Button) findViewById(R.id.backbutton);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.frontmenu);
// Perform action on click
}
});
So my question being, how do I get the buttons on the layout frontmenu to link where they're supposed to? Are there any syntax errors or things I need to add to this code snippet to make it function properly?
Thanks in advance!