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);}
所有startActivity都以红色下划线,并希望我更改为某些内容或创建方法相同的名称。我确实将所有活动添加到清单中,但其中一些活动并不起作用:
<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>
这里很难说,但是其他每一个都是红色的,说它缺少了android命名空间前缀。
欣赏你&#39; ll!
答案 0 :(得分:8)
在您的代码中尝试使用intent来启动活动:
Intent i = new Intent(ACTUALACTIVITY.this, OTHERACTIVITY.class);
startActivity(i);
并在您的清单中放置您的活动完整地址(package.activity),如下所示:
<application>
(...)
<activity
android:name="packagename.YOURACTIVITY">
</activity>
</application>
答案 1 :(得分:0)
尝试创建Intent并启动Activity传递此意图,如
// Create intent to start new Activity
Intent intent = new Intent(context, YourActivity.class);
startActivity(intent);
答案 2 :(得分:-1)
startActivity
方法以Intent
为参数。哟正试图通过一个课程,这就是为什么你得到了#34;红色下划线&#34;
试试这个:
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));}
同样在你的表现中,当你宣布一项活动时,不要忘记关闭引号
<activity android:name=".AbidingInChrist"></activity>
<activity android:name=".AbundantLiving"></activity>
<activity android:name=".AccessToGod"></activity>
等