startActivity not working

999 picture 999 · Jul 17, 2014 · Viewed 24.6k times · Source
        public void onItemClick(AdapterView<?> parent, View view, int position,
            long id) {
        //Toast.makeText(getApplicationContext(), "Position of selected item is: "+   position, Toast.LENGTH_LONG).show();

        if ("Abiding in Christ".equals(categories[position]))
                {startActivity(AbidingInChrist.class);}
        else if ("Abundant Living".equals(categories[position]))
                {startActivity(AbundantLiving.class);}
        else if ("Access to God".equals(categories[position]))
                {startActivity(AccessToGod.class);}
        else if ("Adoration of God".equals(categories[position]))
                {startActivity(AdorationOfGod.class);}
        else if ("Amazing Grace".equals(categories[position]))
                {startActivity(AmazingGrace.class);}

all of the startActivity s are underlined in red and want me to change to something or create a method same name. I did add all the activities to the manifest, but some of them didn't work:

  <activity android:name=".AbidingInChrist"</activity>
    <activity android:name=".AbundantLiving</activity>
    <activity android:name=".AccessToGod</activity>
    <activity android:name=".AdorationOfGod</activity>
    <activity android:name=".AmazingGrace</activity>
    <activity android:name=".AnsweredPrayer</activity>
    <activity android:name=".Atonement</activity>
    <activity android:name=".Attitudes</activity>
    <activity android:name=".Belief</activity>
    <activity android:name=".Blessing</activity>
    <activity android:name=".BloodOfJesus</activity>
    <activity android:name=".Boldness</activity>
    <activity android:name=".Brokenness</activity>
    <activity android:name=".Calling</activity>
    <activity android:name=".Comfort</activity>
    <activity android:name=".Commitment</activity>

It's hard to tell here, but every other one was in red saying that it was missing the android namespace prefix.

Appreciate ya'll!

Answer

PedroHawk picture PedroHawk · Jul 17, 2014

In your code try to use an intent to start activity:

   Intent i = new Intent(ACTUALACTIVITY.this, OTHERACTIVITY.class);
                startActivity(i);

and in your manifest put your activity full address (package.activity) like below:

<application>
(...)
            <activity
                android:name="packagename.YOURACTIVITY">
            </activity>
</application>