[android-beginners] Re: new'ing an Intent

2009-10-28 Thread Mark Murphy



 btw, I have class called RootGameScreen in my workspace, namespace

         button.setOnClickListener(new View.OnClickListener()
         {
             public void onClick(View v)
             {
                 Intent startGameIntent = new Intent(this,
 RootGameScreen.class);

In Java, this refers to the narrowest possible scope by default. So, in
your Intent constructor, this is the View.OnClickListener anonymous
inner class you are defining.

Change your code to:

Intent startGameIntent = new Intent(WelcomeScreen.this,
RootGameScreen.class);

and you may have better luck.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: new'ing an Intent

2009-10-28 Thread Matt Raffel

Mark Murphy wrote:
 
 btw, I have class called RootGameScreen in my workspace, namespace
 
 button.setOnClickListener(new View.OnClickListener()
 {
 public void onClick(View v)
 {
 Intent startGameIntent = new Intent(this,
 RootGameScreen.class);
 
 In Java, this refers to the narrowest possible scope by default. So, in
 your Intent constructor, this is the View.OnClickListener anonymous
 inner class you are defining.
 
 Change your code to:
 
 Intent startGameIntent = new Intent(WelcomeScreen.this,
 RootGameScreen.class);
 
 and you may have better luck.
 

yes that was it.  A newbie error. :)  Thnx

Matt

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: new'ing an Intent

2009-10-27 Thread tatman

btw, I have class called RootGameScreen in my workspace, namespace

On Oct 27, 5:43 pm, tatman matt.raf...@gmail.com wrote:
 In the notepad2.java example, the sample allocates an intent like
 this:

     private void createNote() {
         // TODO: fill in implementation
         Intent i = new Intent(this, NoteEdit.class);
         startActivityForResult(i, ACTIVITY_CREATE);
     }

 I effectively copied that code, changed it fit for me, but it does not
 compile with error constructor doesn't exist.  The quick fix
 according to Eclipse is to remove the parameters.  I'm confusedany
 help would be appreciated

 package com.bigwoo;

 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.Button;

 // startup screen
 public class WelcomeScreen extends Activity
 {
     private static final int ACTIVITY_GAMEON=0;

     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);

         Button button = (Button) findViewById(R.id.startgameBtnId);
         button.setOnClickListener(new View.OnClickListener()
         {
             public void onClick(View v)
             {
                 Intent startGameIntent = new Intent(this,
 RootGameScreen.class);
                 startActivityForResult(startGameIntent,
 ACTIVITY_GAMEON);
             }
         });

     }

 }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: new'ing an Intent

2009-10-27 Thread RichardC

The this you are passing into new Intent is an anonymous derived
class of View.OnClickListener not your derived Activity class
WelcomeScreen.

You will need to ask someone who knows more Java than I do how to get
at this in your outer class.

--
RichardC

On Oct 27, 9:48 pm, tatman matt.raf...@gmail.com wrote:
 btw, I have class called RootGameScreen in my workspace, namespace

 On Oct 27, 5:43 pm, tatman matt.raf...@gmail.com wrote:

  In the notepad2.java example, the sample allocates an intent like
  this:

      private void createNote() {
          // TODO: fill in implementation
          Intent i = new Intent(this, NoteEdit.class);
          startActivityForResult(i, ACTIVITY_CREATE);
      }

  I effectively copied that code, changed it fit for me, but it does not
  compile with error constructor doesn't exist.  The quick fix
  according to Eclipse is to remove the parameters.  I'm confusedany
  help would be appreciated

  package com.bigwoo;

  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;

  // startup screen
  public class WelcomeScreen extends Activity
  {
      private static final int ACTIVITY_GAMEON=0;

      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);

          Button button = (Button) findViewById(R.id.startgameBtnId);
          button.setOnClickListener(new View.OnClickListener()
          {
              public void onClick(View v)
              {
                  Intent startGameIntent = new Intent(this,
  RootGameScreen.class);
                  startActivityForResult(startGameIntent,
  ACTIVITY_GAMEON);
              }
          });

      }

  }


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: new'ing an Intent

2009-10-27 Thread Lance Nanek

Using WelcomeScreen.this instead of this should take care of the
problem Richard pointed out for this case.

On Oct 27, 6:09 pm, RichardC richard.crit...@googlemail.com wrote:
 The this you are passing into new Intent is an anonymous derived
 class of View.OnClickListener not your derived Activity class
 WelcomeScreen.

 You will need to ask someone who knows more Java than I do how to get
 at this in your outer class.

 --
 RichardC

 On Oct 27, 9:48 pm, tatman matt.raf...@gmail.com wrote:

  btw, I have class called RootGameScreen in my workspace, namespace

  On Oct 27, 5:43 pm, tatman matt.raf...@gmail.com wrote:

   In the notepad2.java example, the sample allocates an intent like
   this:

       private void createNote() {
           // TODO: fill in implementation
           Intent i = new Intent(this, NoteEdit.class);
           startActivityForResult(i, ACTIVITY_CREATE);
       }

   I effectively copied that code, changed it fit for me, but it does not
   compile with error constructor doesn't exist.  The quick fix
   according to Eclipse is to remove the parameters.  I'm confusedany
   help would be appreciated

   package com.bigwoo;

   import android.app.Activity;
   import android.content.Intent;
   import android.os.Bundle;
   import android.view.View;
   import android.widget.Button;

   // startup screen
   public class WelcomeScreen extends Activity
   {
       private static final int ACTIVITY_GAMEON=0;

       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState)
       {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);

           Button button = (Button) findViewById(R.id.startgameBtnId);
           button.setOnClickListener(new View.OnClickListener()
           {
               public void onClick(View v)
               {
                   Intent startGameIntent = new Intent(this,
   RootGameScreen.class);
                   startActivityForResult(startGameIntent,
   ACTIVITY_GAMEON);
               }
           });

       }

   }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: new'ing an Intent

2009-10-27 Thread tatman

Thnx.  :)  That was it.

On Oct 27, 6:27 pm, Lance Nanek lna...@gmail.com wrote:
 Using WelcomeScreen.this instead of this should take care of the
 problem Richard pointed out for this case.

 On Oct 27, 6:09 pm, RichardC richard.crit...@googlemail.com wrote:

  The this you are passing into new Intent is an anonymous derived
  class of View.OnClickListener not your derived Activity class
  WelcomeScreen.

  You will need to ask someone who knows more Java than I do how to get
  at this in your outer class.

  --
  RichardC

  On Oct 27, 9:48 pm, tatman matt.raf...@gmail.com wrote:

   btw, I have class called RootGameScreen in my workspace, namespace

   On Oct 27, 5:43 pm, tatman matt.raf...@gmail.com wrote:

In the notepad2.java example, the sample allocates an intent like
this:

    private void createNote() {
        // TODO: fill in implementation
        Intent i = new Intent(this, NoteEdit.class);
        startActivityForResult(i, ACTIVITY_CREATE);
    }

I effectively copied that code, changed it fit for me, but it does not
compile with error constructor doesn't exist.  The quick fix
according to Eclipse is to remove the parameters.  I'm confusedany
help would be appreciated

package com.bigwoo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

// startup screen
public class WelcomeScreen extends Activity
{
    private static final int ACTIVITY_GAMEON=0;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button button = (Button) findViewById(R.id.startgameBtnId);
        button.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                Intent startGameIntent = new Intent(this,
RootGameScreen.class);
                startActivityForResult(startGameIntent,
ACTIVITY_GAMEON);
            }
        });

    }

}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---