我的应用程序突然之间不会在页面之间切换,而且我会收到以下错误,我无法弄清楚我已经改变了什么,或者改变了什么来让它做到这一点。这是错误。我不知道你需要我发布哪个代码,所以请让我知道;
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 :(得分:0)
您的班级AddAsset
缺少空(也就是默认)构造函数
尝试添加构造函数
public AddAsset() { }
请注意
public AddAsset(View view) { ... }
不是空构造函数,因为它有参数。