Thanks!

On May 12, 3:26 am, Justin Anderson <[email protected]> wrote:
> Replace "this" with "MainAct.this"
>
> ----------------------------------------------------------------------
> There are only 10 types of people in the world...
> Those who know binary and those who don't.
> ----------------------------------------------------------------------
>
> On Tue, May 11, 2010 at 5:22 PM, AKninja04 <[email protected]>wrote:
>
>
>
> > Hi, I'm having similar problems as stated above.
>
> > My onClick() method is created in one of my Button setOnClickListener
> > initilizations. Whenever I click my button, a force stop occurs. Here
> > is my code:
>
> > package com.nrg.droidcraft;
>
> > import android.app.Activity;
> > import android.content.Intent;
> > import android.os.Bundle;
> > import android.view.View;
> > import android.widget.Button;
>
> > public class MainAct extends Activity {
> >    /** Called when the activity is first created. */
> >   �...@override
> >    public void onCreate(Bundle savedInstanceState) {
> >        super.onCreate(savedInstanceState);
> >        setContentView(R.layout.main);
> >        initButtons();
> >    }
>
> >    private void initButtons(){
> >        final Button zergbutton = (Button)
> > findViewById(R.id.zergbutton);
> >                zergbutton.setOnClickListener(new View.OnClickListener() {
> >                                public void onClick(View v){
> >                                        Intent zerg = new Intent(this,
> > ZergScreen.class);
> >                                        startActivity(zerg);
> >                                }
> >                        });
>
> >        final Button terranbutton = (Button)
> > findViewById(R.id.terranbutton);
> >        final Button protossbutton = (Button)
> > findViewById(R.id.protossbutton);
> >    }
> > }
>
> > The error it is giving me is that the this is pointing to the
> > View.OnClickListener(), not the Context. Could someone help me
> > correctly implement this method? Thank you.
>
> > AK
>
> > On May 11, 6:41 pm, Ubuntu Explorer <[email protected]> wrote:
> > > Yes, it is in onCreate().
>
> > > And adb helped. I had a problem with my onClickListener API. I fixed
> > > it and now I can switch between activities.
>
> > > Thanks for your persistent help.
>
> > > Regards,
> > > UE.
>
> > > On May 12, 7:31 am, Justin Anderson <[email protected]> wrote:
>
> > > > *> Should I move setContentView() call into onStart() ?*
>
> > > > Where is it now?  It should be in your onCreate() method.  Also, if you
> > get
> > > > a force close, you can find out more information about the exact
> > problem by
> > > > looking at the Logcat output...
>
> > > > ----------------------------------------------------------------------
> > > > There are only 10 types of people in the world...
> > > > Those who know binary and those who don't.
> > > > ----------------------------------------------------------------------
>
> > > > On Tue, May 11, 2010 at 4:27 PM, Ubuntu Explorer
> > > > <[email protected]>wrote:
>
> > > > > I did exactly as what you had adviced.
>
> > > > > However, the issue was Activity1's view is not showing up, when I
> > > > > launch the activity again.
>
> > > > > Should I move setContentView() call into onStart() ?
>
> > > > > Regards,
> > > > > UE
>
> > > > > On May 12, 6:24 am, Justin Anderson <[email protected]> wrote:
> > > > > > Have you even tried using my suggestions?  I am quite certain that
> > if you
> > > > > do
> > > > > > it the way I outlined your problems will go away.
>
> > ----------------------------------------------------------------------
> > > > > > There are only 10 types of people in the world...
> > > > > > Those who know binary and those who don't.
>
> > ----------------------------------------------------------------------
>
> > > > > > On Tue, May 11, 2010 at 3:18 PM, Ubuntu Explorer
> > > > > > <[email protected]>wrote:
>
> > > > > > > Thanks for your suggestions.
>
> > > > > > > I am 50% through. I am able to go from Activity1 to Activity2.
> > > > > > > However, my replica code in Activity2 doesn't work.
>
> > > > > > > Here are my Manifest activity details.
>
> > > > > > >        <activity android:name=".MultipleActivity"
> > > > > > >                  android:label="@string/app_name">
> > > > > > >            <intent-filter>
> > > > > > >                <action android:name="android.intent.action.MAIN"
> > />
> > > > > > >                <category
> > > > > > > android:name="android.intent.category.LAUNCHER" />
> > > > > > >            </intent-filter>
> > > > > > >        </activity>
> > > > > > >        <activity android:name=".MultiActivity1"
> > > > > > >                  android:label="@string/app_name">
> > > > > > >        </activity>
>
> > > > > > > Regards
> > > > > > > UE
>
> > > > > > > On May 12, 6:04 am, Justin Anderson <[email protected]>
> > wrote:
> > > > > > > > Also, you need to make sure you have your activities declared
> > in your
> > > > > > > > Android Manifest file.
>
> > ----------------------------------------------------------------------
> > > > > > > > There are only 10 types of people in the world...
> > > > > > > > Those who know binary and those who don't.
>
> > ----------------------------------------------------------------------
>
> > > > > > > > On Tue, May 11, 2010 at 2:55 PM, Ubuntu Explorer
> > > > > > > > <[email protected]>wrote:
>
> > > > > > > > > Hi,
>
> > > > > > > > > I am trying to write a simple multiple activity application -
> > each
> > > > > of
> > > > > > > which
> > > > > > > > > has a xml layout file (containing a button)
> > > > > > > > > On the button click, the need to switch between the
> > activities.
>
> > > > > > > > > My onClick() looks like this
>
> > > > > > > > > {
> > > > > > > > >         Intent myIntent = new Intent("Multi2");
> > > > > > > > >         Activity act2 = new MultipleActivity();
> > > > > > > > >         act2.startActivity(myIntent);
> > > > > > > > > }
>
> > > > > > > > > And I have exact replica of code in my second activity as
> > well.
>
> > > > > > > > > However, when I click on my button, it freezes. Sometimes,
> > there is
> > > > > a
> > > > > > > force
> > > > > > > > > close warning.
>
> > > > > > > > > What am I doing wrong?
>
> > > > > > > > > Regards,
> > > > > > > > > UE.
>
> > > > > > > > >  --
> > > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > > > > Groups "Android Beginners" group.
>
> > > > > > > > > NEW! Try asking and tagging your question on Stack Overflow
> > at
> > > > > > > > >http://stackoverflow.com/questions/tagged/android
>
> > > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > > [email protected]<android-beginners%2bunsubscr­[email protected]><android-beginners%2Bunsubscr
> > [email protected]>
> > > > > <android-beginners%[email protected]<android-beginners%252buns­[email protected]><android-beginners%252Buns
> > [email protected]>
>
> > > > > > > <android-beginners%[email protected]<android-beginners%252buns­[email protected]><android-beginners%252Buns
> > [email protected]>
> > > > > <android-beginners%[email protected]<android-beginners%25252­[email protected]><android-beginners%25252
> > [email protected]>
>
> > > > > > > > > For more options, visit this group at
> > > > > > > > >http://groups.google.com/group/android-beginners?hl=en
>
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > > > Groups "Android Beginners" group.
>
> > > > > > > > NEW! Try asking and tagging your question on Stack Overflow
> > athttp://
> > > > > > > stackoverflow.com/questions/tagged/android
>
> > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > [email protected]<android-beginners%2bunsubscr­[email protected]><android-beginners%2Bunsubscr
> > [email protected]>
> > > > > <android-beginners%[email protected]<android-beginners%252buns­[email protected]><android-beginners%252Buns
> > [email protected]>
>
> > > > > > > > For more options, visit this group athttp://
> > > > > > > groups.google.com/group/android-beginners?hl=en
>
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > > Groups "Android Beginners" group.
>
> > > > > > > NEW! Try asking and tagging your question on Stack Overflow at
> > > > > > >http://stackoverflow.com/questions/tagged/android
>
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > [email protected]<android-beginners%2bunsubscr­[email protected]><android-beginners%2Bunsubscr
> > [email protected]>
> > > > > <android-beginners%[email protected]<android-beginners%252buns­[email protected]><android-beginners%252Buns
> > [email protected]>
>
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/android-beginners?hl=en
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > > > Groups "Android Beginners" group.
>
> > > > > > NEW! Try asking and tagging your question on Stack Overflow
> > athttp://
> > > > > stackoverflow.com/questions/tagged/android
>
> > > > > > To unsubscribe from this group, send email to
> > > > > > [email protected]<android-beginners%2bunsubscr­[email protected]><android-beginners%2Bunsubscr
> > [email protected]>
> > > > > > For more options, visit this group athttp://
> > > > > groups.google.com/group/android-beginners?hl=en
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Beginners" group.
>
> > > > > NEW! Try asking and tagging your question on Stack Overflow at
>
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to