基本上,我的 boidae 列表活动不会从我的 serpente 列表活动中打开。我不知道为什么,但如果你能帮助我,我确实有日志猫和代码。谢谢你。
我的日志猫:
04-23 19:49:28.327: W/System.err(958): java.lang.ClassNotFoundException: com.xeecros.reptilekeeperBoidae
04-23 19:49:28.327: W/System.err(958): at java.lang.Class.classForName(Native Method)
04-23 19:49:28.366: W/System.err(958): at java.lang.Class.forName(Class.java:217)
04-23 19:49:28.366: W/System.err(958): at java.lang.Class.forName(Class.java:172)
04-23 19:49:28.366: W/System.err(958): at com.xeecros.reptilekeeper.Serpentes.onListItemClick(Serpentes.java:28)
04-23 19:49:28.366: W/System.err(958): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
04-23 19:49:28.366: W/System.err(958): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
04-23 19:49:28.366: W/System.err(958): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
04-23 19:49:28.366: W/System.err(958): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
04-23 19:49:28.376: W/System.err(958): at android.widget.AbsListView$1.run(AbsListView.java:3423)
04-23 19:49:28.376: W/System.err(958): at android.os.Handler.handleCallback(Handler.java:725)
04-23 19:49:28.376: W/System.err(958): at android.os.Handler.dispatchMessage(Handler.java:92)
04-23 19:49:28.376: W/System.err(958): at android.os.Looper.loop(Looper.java:137)
04-23 19:49:28.376: W/System.err(958): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-23 19:49:28.387: W/System.err(958): at java.lang.reflect.Method.invokeNative(Native Method)
04-23 19:49:28.387: W/System.err(958): at java.lang.reflect.Method.invoke(Method.java:511)
04-23 19:49:28.387: W/System.err(958): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-23 19:49:28.387: W/System.err(958): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-23 19:49:28.396: W/System.err(958): at dalvik.system.NativeStart.main(Native Method)
04-23 19:49:28.396: W/System.err(958): Caused by: java.lang.NoClassDefFoundError: com/xeecros/reptilekeeperBoidae
04-23 19:49:28.396: W/System.err(958): ... 18 more
04-23 19:49:28.406: W/System.err(958): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xeecros.reptilekeeperBoidae" on path: /data/app/com.xeecros.reptilekeeper-1.apk
04-23 19:49:28.406: W/System.err(958): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
04-23 19:49:28.406: W/System.err(958): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-23 19:49:28.406: W/System.err(958): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-23 19:49:28.416: W/System.err(958): ... 18 more
我的博科班:
/*
* This class is a list to contain
* all of the classes for the individual species.
*/
package com.xeecros.reptilekeeper;
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 Boidae extends ListActivity {
String boaspecies[] = {"Charina bottae"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Boidae.this,
android.R.layout.simple_list_item_1, boaspecies));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String localposm = boaspecies[position];
try{
Class ourclass = Class.forName("com.xeecros.reptilekeeper" + localposm);
Intent bintent = new Intent(Boidae.this, ourclass);
startActivity(bintent);
}catch (ClassNotFoundException e){
e.printStackTrace();
}
}
}
我的蛇类:
package com.xeecros.reptilekeeper;
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 Serpentes extends ListActivity {
String snakefam[] = {"Boidae", "Colubridae",
"Elapidae", "Pythonidae", "Viperidae"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Serpentes.this,
android.R.layout.simple_list_item_1, snakefam));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String localposm = snakefam[position];
try{
Class ourclass = Class.forName("com.xeecros.reptilekeeper" + localposm);
Intent sintent = new Intent(Serpentes.this, ourclass);
startActivity(sintent);
}catch (ClassNotFoundException e){
e.printStackTrace();
}
}
}
另外,我还有另一个问题:我如何更改列表的外观,因为我不能使用 xml,因为它是一个 ArrayAdapter。
谢谢你。