我有以下活動, 時startactivity()被調用的應用程序被強制關閉,我正在尋找失敗已經是幾天,任何人可以幫助我嗎?startactivity()關閉應用程序下來
應用:
package com.example.deceunincktechniekers;
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 OpeningsMenu extends ListActivity {
//hier maken we de Array (lijst) met de namen die in de menu moeten komen
String classes[] = {"bezoekrapporten" ,"BTWcontrole" ,"voorbeeld3"};
// hier zetten we de layout van deze class niet gelijk aan een xml maar aan een lijst van knoppen volgens simple list item 1
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(OpeningsMenu.this, android.R.layout.simple_list_item_1, classes));
}
// hier zetten we de actie als er op de lijst geklikt wordt
//
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
//
super.onListItemClick(l, v, position, id);
String positie = classes[position];
try{
Class onzeclass = Class.forName("com.example.deceunincktechniekers." + positie);
Intent onzeIntent = new Intent(OpeningsMenu.this, onzeclass);
startActivity(onzeIntent);
}catch (ClassNotFoundException e){
e.printStackTrace();
}
}
的logcat:
07-13 12:48:47.204: D/dalvikvm(785): GC_CONCURRENT freed 73K, 8% free 2768K/2984K, paused 14ms+57ms, total 148ms
07-13 12:48:47.664: I/Choreographer(785): Skipped 81 frames! The application may be doing too much work on its main thread.
07-13 12:48:47.714: D/gralloc_goldfish(785): Emulator without GPU emulation detected.
07-13 12:53:35.678: D/dalvikvm(785): newInstance failed: Lcom/example/deceunincktechniekers/bezoekrapporten; not accessible to Landroid/app/Instrumentation;
07-13 12:53:35.678: D/AndroidRuntime(785): Shutting down VM
07-13 12:53:35.678: W/dalvikvm(785): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
07-13 12:53:35.738: E/AndroidRuntime(785): FATAL EXCEPTION: main
07-13 12:53:35.738: E/AndroidRuntime(785): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.deceunincktechniekers/com.example.deceunincktechniekers.bezoekrapporten}: java.lang.IllegalAccessException: access to class not allowed
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.os.Handler.dispatchMessage(Handler.java:99)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.os.Looper.loop(Looper.java:137)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-13 12:53:35.738: E/AndroidRuntime(785): at java.lang.reflect.Method.invokeNative(Native Method)
07-13 12:53:35.738: E/AndroidRuntime(785): at java.lang.reflect.Method.invoke(Method.java:511)
07-13 12:53:35.738: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-13 12:53:35.738: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-13 12:53:35.738: E/AndroidRuntime(785): at dalvik.system.NativeStart.main(Native Method)
07-13 12:53:35.738: E/AndroidRuntime(785): Caused by: java.lang.IllegalAccessException: access to class not allowed
07-13 12:53:35.738: E/AndroidRuntime(785): at java.lang.Class.newInstanceImpl(Native Method)
07-13 12:53:35.738: E/AndroidRuntime(785): at java.lang.Class.newInstance(Class.java:1319)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
07-13 12:53:35.738: E/AndroidRuntime(785): ... 11 more
07-13 12:53:38.838: I/Process(785): Sending signal. PID: 785 SIG: 9
,如果你需要更多的信息,請自討苦吃
' 「com.example.deceunincktechniekers。」 + positie)'=你是否在清單中聲明瞭所有這些活動? – Simon