Okay, I see.  That clears up a lot.

Thank you.



On Mar 12, 9:47 pm, Justin Anderson <magouyaw...@gmail.com> wrote:
> *> I know what "this" is.  What is confusing is that a lot of developers
>
> > are using <class name>.this.  It does not make sense to me to use <class
> > name>.this.  When I see <class name>.something it looks like a static
> > access.*
>
> That syntax is only used for an inner class to access the outer class...
> Here is a simple example:
>
> public class A
> {
>      protected int x;
>      protected B instanceOfB;
>
>      public A()
>      {
>           x = 5;
>           instanceOfB = new B();
>
>           instanceOfB.getX(); //returns 6
>           instanceOfB.getOuterX(); //returns 5
>      }
>
>      public class B
>      {
>           protected int x;
>           public B()
>           {
>                x = 6;
>           }
>
>           public int getX()
>           {
>                 return this.x;
>           }
>
>           public int getOuterX()
>           {
>                 return A.this.x;
>           }
>      }
>
> }
>
> Hope this little example clears things up a bit... Obviously this is
> extremely simplified, but it shows when to use "this" and when to use
> "<ClassName>.this"
>
> Thanks,
> Justin Anderson
> MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
>
>
>
>
>
>
> On Mon, Mar 12, 2012 at 8:43 PM, bob <b...@coolfone.comze.com> wrote:
> > I know what "this" is.  What is confusing is that a lot of developers
> > are using
> > <class name>.this.  It does not make sense to me to use <class
> > name>.this.  When I see <class name>.something it looks like a static
> > access.
>
> > On Mar 12, 3:02 pm, Justin Anderson <magouyaw...@gmail.com> wrote:
> > > Remove the Main_Activity part... It isn't needed.
>
> > > You should probably brush up a bit on Java as well... Here is a link to
> > > some info about how and why "this" works the way it does:
> >http://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html
>
> > > Thanks,
> > > Justin Anderson
> > > MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
> > > On Mon, Mar 12, 2012 at 3:36 PM, bob <b...@coolfone.comze.com> wrote:
> > > > I don't understand why it lets me do something like this in onCreate:
>
> > > > Context c = Main_Activity.this;
>
> > > > That sure looks like a static access.
>
> > > > On Mar 12, 12:46 pm, Justin Anderson <magouyaw...@gmail.com> wrote:
> > > > > What does your code look like?  The "this" keyword is not accessed
> > > > > statically... it is a member of your class instance.
>
> > > > > Thanks,
> > > > > Justin Anderson
> > > > > MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
> > > > > On Mon, Mar 12, 2012 at 1:42 PM, bob <b...@coolfone.comze.com>
> > wrote:
> > > > > > I tried accessing Main_Activity.this, but Eclipse says:
>
> > > > > > No enclosing instance of the type Main_Activity is accessible in
> > > > > > scope.
>
> > > > > > I don't know why it won't let me do it.
>
> > > > > > On Mar 12, 11:44 am, Carlos Silva <r3...@r3pek.org> wrote:
> > > > > > > "this" on a class that extends Activity isn't simple enough?
>
> > > > > > > On Mon, Mar 12, 2012 at 17:39, bob <b...@coolfone.comze.com>
> > wrote:
> > > > > > > > Why is there no static function like
> > Activity.getCurrentActivity()?
>
> > > > > > > > Right now, I am saving the Activity in a static variable in
> > > > onCreate
> > > > > > > > so I can access it easily later on.  I suspect there must be a
> > > > better
> > > > > > > > way.
>
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > > > Groups "Android Developers" group.
> > > > > > > > To post to this group, send email to
> > > > > > android-developers@googlegroups.com
> > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > android-developers+unsubscr...@googlegroups.com
> > > > > > > > For more options, visit this group at
> > > > > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > > > Groups "Android Developers" group.
> > > > > > To post to this group, send email to
> > > > android-developers@googlegroups.com
> > > > > > To unsubscribe from this group, send email to
> > > > > > android-developers+unsubscr...@googlegroups.com
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to
> > android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

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

Reply via email to