我正在尝试使用 android 制作我的第一个列表适配器,它提供了列表,但是当我单击这些项目时,没有任何反应。我唯一的猜测是我在定义 Class cvar 的那一行之后的注释。
package scouting.form;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Menu extends ListActivity{
String classes[] = {"SCOUTING","LOGIN","MAIN"};
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this,android.R.layout.simple_list_item_1,classes));
}
@Override
protected void onListItemClick(ListView l, View v, int position,long id)
{
super.onListItemClick(l, v, position, id);
String cheese= "com.cody.graham."+classes[position];
try{
Class cvar=Class.forName(cheese); //Eclipse has a warning on this line "Class is a raw type. References to generic type Class<T> should be parameterized". I don't really know what that means.
Intent intention=new Intent(Menu.this,cvar);
startActivity(intention);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
编辑:
AndroidManifest 的一部分:
<activity android:name=".splash_screen" android:label="@string/title_activity_splash" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Login" android:label="@string/title_activity_login" android:exported="false">
<intent-filter>
<action android:name="com.cody.graham.LOGIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".Scouting" android:label="@string/title_activity_scouting" android:exported="false">
<intent-filter>
<action android:name="com.cody.graham.SCOUTING" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>