Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
25 May, 2013, 07:17:12 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: [Java] What's going wrong? -  (Read 289 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Ikkerens
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 10 April, 2013, 19:11:45
Date Registered: 12 June, 2010, 13:23:23
Location: Below a falling block.
Posts: 379


Topic starter
Total Post Ratings: +19

View Profile WWW
« on: 02 March, 2011, 09:29:08 »
0

Well, the Android version of Splut is slowly coming along, if the language would stop being so pricky  Mad
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 Wink
« Last Edit: 02 March, 2011, 18:45:22 by Ikkerens » Logged


Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 04:23:20
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50233


Total Post Ratings: +2615

View Profile WWW
« Reply #1 on: 03 March, 2011, 02:14:31 »
0

Glad you figured it out ^^. I'll leave this intact, though, in case someone has a similar issue later.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.183 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.