Well, the Android version of Splut is slowly coming along, if the language would stop being so pricky

Anyway, I was wondering if anyone could help me with this,
I have 2 screens (XML format, named gamescreen & main), and at the moment I'm testing it.
Both buttons work, unless I return to the previous screen.
(Basically, I press 1 button to go to gamescreen, works, press the button to go back to the main, works, try to go the gamescreen again, fails.)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| package com.walotech.splut;
import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.Button;
public class Main extends Activity { @Override public void onCreate(Bundle savedInstanceState) { //Prepare screen //Set landscape orientation setRequestedOrientation(0); //Remove title bar requestWindowFeature(Window.FEATURE_NO_TITLE); //Remove taskbar getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //Load XML for UI super.onCreate(savedInstanceState); setContentView(R.layout.main); //Assign buttons findViewById(R.id.Lev1Start).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { setContentView(R.layout.gamescreen); findViewById(R.id.gbck).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { setContentView(R.layout.main); } }); } }); findViewById(R.id.makeblue).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { Button StartButton = (Button) findViewById(R.id.Lev1Start); StartButton.setBackgroundColor(Color.BLUE); } }); } public void AB_main() { findViewById(R.id.Lev1Start).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { setContentView(R.layout.gamescreen); AB_gamescreen(); } }); findViewById(R.id.makeblue).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { Button StartButton = (Button) findViewById(R.id.Lev1Start); StartButton.setBackgroundColor(Color.BLUE); } }); } public void AB_gamescreen() { findViewById(R.id.gbck).setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { setContentView(R.layout.main); AB_main(); } }); } }
|
Edit:
Already figured it out, seems I was redefining something that was already given in a function 