Results 1 to 5 of 5
  1. #1
    fresh83 is offline Member
    Join Date
    Dec 2009
    Posts
    55
    Rep Power
    0

    Default Errors with start method,annotation name,interface indentife

    ik this is android but i fig its basic enough this section could help me out


    So i decided to try my hand at my first app without guidance from a tutorial and as i expected its been less then a smooth process. The game when started will make one out of 3 buttons appear and give users a few seconds to press it and if they dont get it in time...game over.

    theres more to it id like to add but, if i could just get that far with something compilable id be happy at this point and would work my way up from there. Heres what i came up with so far. Any tips/suggestions/critiques or noticeable errors would be helpful at this point. id even be willing to pay someone to guide me threw this.
    (i realize i only added one of the 4 buttons in this code but, the code from the first will just be duplicated 3 times once i get the first one up and running.)

    errors read as follows:
    Syntax error on token "void", @ expected
    Syntax error on token "while", invalid AnnotationName
    Syntax error, insert "Identifier (" to complete ConstructorHeaderName
    Syntax error, insert "interface Identifier" to complete InterfaceHeader

    Java Code:
    package com.bopit.android;
    
    import java.util.Random;
    
    import android.os.CountDownTimer;
    import android.widget.Button;
    
    
    protected static void start() {
    
    
    		
    	  	   boolean gameIsAlive = true;
    	  	   Random dice = new Random();
    	  	   int nextCommand;
    	  	   
    	  	   while(gameIsAlive) {
    	  		   nextCommand = 1+dice.nextInt(4);
    	  		   
    	  		   
    	  		   if(nextCommand=1);{
    	  		       
    	  			      new CountDownTimer(30000,1000) {
    	  			         public void onTick(long millisUntilFinished) {
    	  			           
    	  			           //this is where i think i need to insert the button and animation to go with it but,
    	  			           //i need it to only appear when this method is called
    	  			           
    	  			          mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
    	  			          
    	  			          //button1
    	  			          Button bTutorial1 = (Button) findViewById(R.id.tutorial1);
    	  			   
    	  			          bTutorial1.setOnClickListener(new View.OnClickListener() { 
    	  			            @Override
    	  			            public void onClick(View v) {
    	  			              // TODO Auto-generated method stub
    	  			            
    	  			              gameStart.start();
    	  			    }
    	  			          });
    	  			      }
    
    							@Override
    							public void onFinish() {
    								// TODO Auto-generated method stub
    							}; }; }; }; }

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,560
    Rep Power
    25

    Default

    What lines do the errors occur on? Did the error message include the line number?

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,415
    Rep Power
    20

    Default

    Android or Java, this is incredibly ugly.
    Java Code:
    							}; }; }; }; }
    Code Conventions for the Java(TM) Programming Language: Contents

    db

    edit And I'm sure Android treats an empty statement after an if block the same way as Java does.
    Java Code:
    if(nextCommand=1);{
    Last edited by DarrylBurke; 05-19-2011 at 03:13 PM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    I could be wrong, but doesn't Android use classes the same way as Java?
    In which case:
    Java Code:
    import android.widget.Button;
    
    
    protected static void start() {
    where's the class declaration?

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by fresh83 View Post
    ik this is android but i fig its basic enough this section could help me out
    errors read as follows:
    Syntax error on token "void", @ expected
    Syntax error on token "while", invalid AnnotationName
    Syntax error, insert "Identifier (" to complete ConstructorHeaderName
    Syntax error, insert "interface Identifier" to complete InterfaceHeader

    Java Code:
    package com.bopit.android;
    
    import java.util.Random;
    
    import android.os.CountDownTimer;
    import android.widget.Button;
    
    
    protected static void start() {
    [ ... ]
    You can't have a method on its own; it has to be defined in a class; that's what your compiler is complaining about.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Using main method to start off app
    By garrym in forum New To Java
    Replies: 3
    Last Post: 04-12-2011, 11:17 PM
  2. Replies: 4
    Last Post: 03-29-2011, 07:34 AM
  3. Interface and abstract method
    By cheesehead11 in forum New To Java
    Replies: 14
    Last Post: 02-08-2011, 06:32 AM
  4. Replies: 5
    Last Post: 02-04-2009, 01:20 AM
  5. Replies: 9
    Last Post: 08-08-2007, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •