firebaseプロジェクトで大変忙しく働いています。このエラーが発生しました itコンパイル中にこのエラーが表示され続けます。ここでエラー:(93,34)エラー:コンストラクタRequestクラスのリクエストは特定の型には適用できません理由:実際の引数リストと正式な引数リストの長さが異なります
Error:(93, 34) error: constructor Request in class Request cannot be applied to given types; required: Uri,int,String,List<Transformation>,int,int,boolean,boolean,boolean,float,float,float,boolean,Config,Priority found: String,String,String,String,List<Order> reason: actual and formal argument lists differ in length
私のカートクラスは
public class Cart extends AppCompatActivity {
RecyclerView recyclerView; RecyclerView.LayoutManager layoutManager; FirebaseDatabase database; DatabaseReference requests; TextView txtTotalPrice; FButton btnPlace; List<Order> cart = new ArrayList<>(); CartAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cart); // init firebase database = FirebaseDatabase.getInstance(); requests = database.getReference("Requests"); //Init recyclerView = (RecyclerView) findViewById(R.id.listCart); recyclerView.setHasFixedSize(true); layoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManager); txtTotalPrice = (TextView) findViewById(R.id.total); btnPlace = (FButton) findViewById(R.id.btnPlaceOrder); btnPlace.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showAlertDialog(); } }); loadListFood(); } private void showAlertDialog() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(Cart.this); alertDialog.setTitle("One More Step!"); alertDialog.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); alertDialog.setView(edtAddress);//Add edit Text to alert dialog alertDialog.setIcon(R.drawable.ic_shopping_cart_black_24dp); alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //Create new Request Request request = new Request( Common.currentUser.getPhone(), Common.currentUser.getName(), edtAddress.getText().toString(), txtTotalPrice.getText().toString(), cart ); //Submit to Firebase //We will using System.CurrentMilli to key requests.child(String.valueOf((System.currentTimeMillis()))).setValue(request); //Delete Cart new Database(getBaseContext()).cleanCart(); Toast.makeText(Cart.this, "Thank you , Order Placed", Toast.LENGTH_SHORT).show(); finish(); } }); alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); alertDialog.show(); } private void loadListFood() { cart = new Database(this).getCarts(); adapter = new CartAdapter(cart, this); recyclerView.setAdapter(adapter); //calculate total price int total = 0; for (Order order : cart) total += (Integer.parseInt(order.getPrice())) * (Integer.parseInt(order.getQuantity())); Locale locale = new Locale("en", "US"); NumberFormat fmt = NumberFormat.getCurrencyInstance(locale); txtTotalPrice.setText(fmt.format(total)); } }
であり、ここで私のコンストラクタクラス要求 パッケージgame.bakarunlimited.com.androideatit.Modelです。
import java.util.List; /** * Created by gaurang on 9/23/2017. */ public class Request {
private String phone; private String name; private String address; private String total; private List<Order> foods; // list of food Order public Request(){ } public Request(String phone, String name, String address,String total, List<Order> foods) { this.phone = phone; this.name = name; this.address = address; this.total = total; this.foods = foods; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getTotal() { return total; } public void setTotal(String total) { this.total = total; } public List<Order> getFoods() { return foods; } public void setFoods(List<Order> foods) { this.foods = foods; } }
ブロック引用符ではなくコードに '{}'エディタボタンを使用してください –