For my android project, most data are save from database and my app will fetch it. However, I have two dialog box that will set dates to two text views and then save it to my database. I'm trying to use currentBeach.setCheckIn(checkInTV.getText().toString()) which causes my program to have an error on constructor. What is the solution for here?
Details.java
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Database(getBaseContext()).addToCart(new Order(
menuID,
currentBeach.getName(),
currentBeach.getPrice(),
currentBeach.setCheckIn(checkInTV.getText().toString()),
currentBeach.setCheckOut(checkOutTV.getText().toString())
));
Intent intent = new Intent(details.this, Cart.class);
startActivity(intent);
}
});
Order.Java (Constructor)
public Order(String productId, String productName, String description, String price, String checkIn, String checkOut) {
ProductId = productId;
ProductName = productName;
Description = description;
Price = price;
this.checkIn = checkIn;
this.checkOut = checkOut;
}
Help me please. Thanks everyone :)
You not passing the description
as argument in Order
constructor
Your Order
constructor has 6 arguments while you are passing 5 arguments inside btnSubmit.setOnClickListener()
check it
Another issue wascurrentBeach.setCheckIn(checkInTV.getText().toString())
and currentBeach.setCheckOut(checkOutTV.getText().toString()
this method returning void while you need to pass String
value in Order
constructor
SAMPLE CODE
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Database(getBaseContext()).addToCart(new Order(
menuID,
currentBeach.getName(),
"description",// pass descriptiion here
currentBeach.getPrice(),
checkInTV.getText().toString(),
checkOutTV.getText().toString())
));
Intent intent = new Intent(details.this, Cart.class);
startActivity(intent);
}
});