2012-10-17 68 views
0

我的應用程序突然不會在頁面之間切換,並且出現以下錯誤,我無法弄清楚我已更改了什麼,或者更改了哪些內容以使其可以這樣做。這是錯誤。我不知道你需要我發佈哪些代碼,所以請讓我知道;Android應用程序在加載時突然摔倒

10-17 16:02:51.720: D/dalvikvm(4436): newInstance failed: no <init>() 
10-17 16:02:51.720: D/AndroidRuntime(4436): Shutting down VM 
10-17 16:02:51.720: W/dalvikvm(4436): threadid=1: thread exiting with uncaught exception (group=0x40c6a1f8) 
10-17 16:02:51.730: E/AndroidRuntime(4436): FATAL EXCEPTION: main 
10-17 16:02:51.730: E/AndroidRuntime(4436): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.directenquiries.assessment.tool/com.directenquiries.assessment.tool.AddAsset}: java.lang.InstantiationException: can't instantiate class com.directenquiries.assessment.tool.AddAsset; no empty constructor 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1894) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.app.ActivityThread.access$600(ActivityThread.java:128) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.os.Handler.dispatchMessage(Handler.java:99) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.os.Looper.loop(Looper.java:137) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.app.ActivityThread.main(ActivityThread.java:4517) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at java.lang.reflect.Method.invokeNative(Native Method) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at java.lang.reflect.Method.invoke(Method.java:511) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at dalvik.system.NativeStart.main(Native Method) 
10-17 16:02:51.730: E/AndroidRuntime(4436): Caused by: java.lang.InstantiationException: can't instantiate class com.directenquiries.assessment.tool.AddAsset; no empty constructor 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at java.lang.Class.newInstanceImpl(Native Method) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at java.lang.Class.newInstance(Class.java:1319) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.app.Instrumentation.newActivity(Instrumentation.java:1027) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1885) 
10-17 16:02:51.730: E/AndroidRuntime(4436):  ... 11 more 

湯姆

編輯:新增股票代號

public AddAsset(View view){ 

     String Barcode = tbBarcode.getText().toString(); 
     String LongDescription = tbLongDescription.getText().toString(); 
     String LocalReference = tbLocalReference.getText().toString(); 
     String Quantity = tbQuantity.getText().toString(); 

     String VisualCondition = "VisualCondition"; 

     String NewAssetStationObjectID = DBFunctions.getNextID(Global.StationID, "StationObjects"); 

     if(DBFunctions.isBarcodeUnique(Barcode, StationObjectID).equals("True")){ 

      DBFunctions.addAsset(NewAssetStationObjectID, Barcode, AssetType, AssetGroup, AssetSubGroup, " ", LocalReference, LongDescription, VisualCondition, Quantity, StationObjectID, " ", "Y"); 

     } else { 

      ShowAlert("Duplicate Barcode", "This barcode has already been used"); 
     } 


    } 

回答

0

你的類AddAsset缺乏一個空(又名默認)構造

嘗試添加構造

public AddAsset() { } 

注意

public AddAsset(View view) { ... } 

不是一個空的構造,因爲它有參數。

+0

嘿,謝謝 - 我在右頁添加了上面的資源代碼(剛剛添加)。你介意看看更新後的代碼嗎? – TMB87