Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old April 4th, 2010, 08:37 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Apr 2010
Posts: 12
 
Device(s): Moto Droid Bionic
Carrier: Not Provided

Thanks: 2
Thanked 0 Times in 0 Posts
Post Developer Newbiew- 2 Questions...

Hi, my name is Jamie, and I am an aspiring android app developer. I've read a few tutorials, ebooks, etc. and starting going around developing my first app, which is a game.

First of all, making the main menu for my game, i started to set up the about and how-to-play pages (by creating a separate class for each). Anyway, when in emulation, the about button works, but the how to play button does nothing when clicked. I double checked id's, activity names, and eclipse finds nothing wrong with my code. Here is the code for the activity as it deals to this problem.

Code:
public class Robot_Invasion extends Activity implements OnClickListener {
    
    public void onClick(View v) {
        switch(v.getId()){
        case R.id.about:
            Intent a = new Intent(this, About.class);
            startActivity (a);
        switch(v.getId()){
        case R.id.help:
            Intent h = new Intent(this, Howtoplay.class);
            startActivity (h);
            break;
        }
        }
    
    }
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
   

        
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    
    View campaignButton = findViewById(R.id.campaign);
    campaignButton.setOnClickListener(this);
    View sandboxButton = findViewById(R.id.sandbox);
    sandboxButton.setOnClickListener(this);
    View howtoplayButton = findViewById(R.id.help);
    howtoplayButton.setOnClickListener(this);
    View aboutButton = findViewById(R.id.about);
    aboutButton.setOnClickListener(this);
Also, regarding game engine development, has anyone found any good ebooks or tutorials, because I am totally in the dark about that concept, and I am doing all the graphical and layout development before-hand, but I would life to start learning that part.

Thanks in advance,

Jamie

manurules3 is offline  
Last edited by manurules3; April 5th, 2010 at 01:03 PM.
Reply With Quote
sponsored links
Old April 5th, 2010, 03:50 AM   #2 (permalink)
Senior Member
 
KlaymenDK's Avatar
 
Join Date: May 2009
Location: Denmark
Posts: 1,221
 
Device(s): HTC Desire Z (rooted, CyanogenMod v7.1; Revoked ClockworkMod) HTC Desire (rooted, Oxygen rom; Revoke
Carrier: Not Provided

Thanks: 31
Thanked 132 Times in 100 Posts
Default

Welcome to the forum!

Sorry, not much help from me (reading code like that hurts my brain, please use the "#" (code) tag next time.

Also, searching for android game development brings up many interesting results, the one from Robert Green is quite good.
__________________
Don't forget to hit the "Thanks" button when someone helps you!!!
How To Ask Questions The Smart Way
-- 010\001\111 --
KlaymenDK is offline  
Reply With Quote
The Following User Says Thank You to KlaymenDK For This Useful Post:
manurules3 (April 5th, 2010)
Old April 6th, 2010, 07:46 AM   #3 (permalink)
Member
 
Join Date: Apr 2010
Posts: 170
 
Device(s):
Carrier: Not Provided

Thanks: 15
Thanked 12 Times in 11 Posts
Default

I am guessing you have already figured out what is wrong with your code, but if not...

The issue is around the switch statement, and how you have written it to work. As written, you have the code for the help button is actually inside the case for the about button. In order to fix the issue, you will need to add a break statement after "startActivity (a);", and remove the second switch statement (you should only need one switch for all the cases...

Hope that helps.
Schwin97 is offline  
Reply With Quote
The Following User Says Thank You to Schwin97 For This Useful Post:
manurules3 (April 7th, 2010)
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:50 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.