在做一個食品應用程序項目時,我的 cleanCart() 方法遇到了問題。這是我的堆棧跟蹤:error: method cleanCart in class Database cannot be applied to given types; new Database(getBaseContext()).cleanCart(); ^ required: Order found: no arguments reason: actual and formal argument lists differ in lengthNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.1 errorFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:compileDebugJavaWithJavac'.> Compilation failed; see the compiler error output for details.這是我的 Cart.java 類private void showAlertDialogue() { AlertDialog.Builder alertDialogue=new AlertDialog.Builder(Cart.this); alertDialogue.setTitle("One more step!"); alertDialogue.setMessage("Enter your address :"); final EditText edtAddress=new EditText(Cart.this); LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT ); edtAddress.setLayoutParams(lp); alertDialogue.setView(edtAddress); //Add edit text to alert dialog alertDialogue.setIcon(R.drawable.ic_shopping_cart_black_24dp); alertDialogue.setPositiveButton("YES", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Create new request Request request=new Request( Common.currentUser.getPhone(), Common.currentUser.getName(), txtTotalPrice.getText().toString(), edtAddress.getText().toString(), cart );
1 回答

慕妹3146593
TA貢獻1820條經驗 獲得超9個贊
這有點難以理解,但看起來這會給您帶來錯誤,因為您的cleanCart方法有一個Order order需要根據數據庫類傳入的參數。
但是,當您調用該方法時,調用該方法時不帶任何參數。
因為您根本沒有Order在cleanCart方法中使用對象,所以可以從方法中刪除參數,如下所示:
數據庫類:
public void cleanCart() { // remove parameter
SQLiteDatabase db = getReadableDatabase();
String query = String.format("DELETE FROM OrderDetail");
db.execSQL(query);
}
添加回答
舉報
0/150
提交
取消