4
        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!

999
  • 83
  • 1
  • 1
  • 9

4 Answers4

10

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>
PedroHawk
  • 622
  • 5
  • 19
0

Try to create Intent and start Activity passing this intent like

// Create intent to start new Activity
Intent intent = new Intent(context, YourActivity.class);
startActivity(intent);
krodmannix
  • 845
  • 10
  • 30
Lanitka
  • 922
  • 1
  • 10
  • 20
  • Yes, I see but how do I pass it the selected position as the class (activity) to start? – 999 Jul 19 '14 at 14:42
  • sunladyjoy, you can use overloaded methods of Intent class putExtra() where you pass data using KEY-VALUE pairs. Then, other activity, which you have started by your intent, can retrieve passed values, using methods with get(SOMETHING)Extra() and use your values as you need – Lanitka Jul 22 '14 at 13:14
0

I know that this is an old question. Might be a bit irrelevant to the question details. But hopefully, might help someone who lands on this question for a similar issue.

In my case, "context.startActivity(...)" was supposed to launch an activity in a pendingIntent (when the app is in the background). It wasn't working because I had "Display over other apps" set as "Not allowed", in the application settings. Added the permission for the same and enabled it, to resolve the issue.

Melvin
  • 351
  • 4
  • 10
-2

The startActivity method takes an Intent as parameter. Yo are trying to pass a class and that's why you get the "red underline"

try this:

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

Also in you manifest don't forget to close the quotes when you declare an activity

        <activity android:name=".AbidingInChrist"></activity>
        <activity android:name=".AbundantLiving"></activity>
        <activity android:name=".AccessToGod"></activity>

etc

Carlos J
  • 2,965
  • 4
  • 17
  • 28