输入数字时的NumberFormatException

时间:2018-05-02 10:21:21

标签: android

我想从我的提案类中获取数据并将其显示在我的购物车类中,但我一直收到NumberFormatException的错误。

我尝试通过输入文字或数字来解决它,但我仍然得到同样的错误。请帮助。

05-02 13:00:20.754 11145-11145/hushtagstudios.com.towme E/AndroidRuntime: FATAL EXCEPTION: main
Process: hushtagstudios.com.towme, PID: 11145
java.lang.RuntimeException: Unable to start activity ComponentInfo{hushtagstudios.com.towme/hushtagstudios.com.towme.Cart}: java.lang.NumberFormatException: For input string: ""
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
 Caused by: java.lang.NumberFormatException: For input string: ""
    at java.lang.Integer.parseInt(Integer.java:620)
    at java.lang.Integer.parseInt(Integer.java:643)
    at hushtagstudios.com.towme.Cart.onCreate(Cart.java:1151)
    at android.app.Activity.performCreate(Activity.java:6975)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
    at android.app.ActivityThread.-wrap11(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
    at android.os.Handler.dispatchMessage(Handler.java:105) 
    at android.os.Looper.loop(Looper.java:164) 
    at android.app.ActivityThread.main(ActivityThread.java:6541) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

这是我的Cart.class

public class Cart extends AppCompatActivity {

RecyclerView recyclerView;
RecyclerView.LayoutManager layoutManager;

FirebaseDatabase database;
DatabaseReference requests;

TextView txtTotalPrice;

List<Order> cart = new ArrayList<>();

CartAdapter adapter;

Button btnPay;
Button btnNew;
ImageView ivPaymentMethod;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cart);
    Toolbar toolbar = (Toolbar) findViewById(hushtagstudios.com.towme.R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    btnNew = (Button)findViewById(R.id.btnNew);
    btnNew.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent anotherInsurance = new Intent(Cart.this,BuyInsurance.class);
            startActivity(anotherInsurance);
        }
    });

    btnPay = (Button)findViewById(R.id.btnPay);
    btnPay.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            showAlertDialog();

            String totalPrice = txtTotalPrice.getText().toString();

            Intent intentPrice = new Intent(v.getContext(),InsurancePayment.class);
            intentPrice.putExtra("totalPrice", totalPrice);

            startActivity(intentPrice);
            //Create new Request





            Intent payRequest = new Intent(Cart.this,InsurancePayment.class);
            startActivity(payRequest);
        }
    });


    database = FirebaseDatabase.getInstance();
    requests = database.getReference("OrderRequests");


    recyclerView = (RecyclerView)findViewById(R.id.listCart);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);

    txtTotalPrice = (TextView)findViewById(R.id.txtTotal);

    loadListProposals();


}

private void showAlertDialog() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(Cart.this);
    alertDialog.setTitle("Final step!");
    alertDialog.setMessage("Enter your delivery location: ");

    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);
    alertDialog.setIcon(R.drawable.ic_cart_black);

    alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            RequestDelivery requestDelivery = new RequestDelivery(
                    Common.currentUser.getPhone(),
                    Common.currentUser.getLastName(),
                    cart,
                    Common.currentUser.getFirstName(),
                    txtTotalPrice.getText().toString(),
                    edtAddress.getText().toString());

            requests.child(String.valueOf(System.currentTimeMillis()))
                    .setValue(requestDelivery);
        }
    });
}

private void loadListProposals() {
    cart = new Database(this).getCarts();
    adapter = new CartAdapter(cart,this);
    recyclerView.setAdapter(adapter);


    //Calculate totalPremium

    int total = 0;
    for (Order order:cart)
        total+=(Integer.parseInt(order.getTotalPremium()))* (Integer.parseInt(order.getProposalId()));
    Locale locale = new Locale("sw", "KE");
    NumberFormat fmt = NumberFormat.getCurrencyInstance(locale);

    txtTotalPrice.setText(fmt.format(total));

}
@Override
public void onBackPressed() {
    Intent openNewInsurance = new Intent(Cart.this, ProposalForm1.class);
    startActivity(openNewInsurance);
    finish();
}
@Override
public boolean onSupportNavigateUp() {
    onBackPressed();
    return true;
}
}

这是我的ProposalForm1.class,其中vehicleReg数据来自。{所以我应该将车辆登记发布到数据库,然后检索并显示在Cart.class

public class ProposalForm1 extends AppCompatActivity implements View.OnClickListener {

static final int DATE_DIALOG_ID = 0;
private int mYear,mMonth,mDay;
private String vehicleMake,totalPremium,typeOfCoverage,vehicleModel,yearOfManf, stampDuty,marketValue
,policyHolders,firstNameProposer,lastNameProposer,surnameProposer, idNumber, pinNo,excessProtector, terrorism, basicPremium,
        email, mobile, drivingTime, PeriodFrom, PeriodTo, vehicleReg,
    trainingLevy,windscreenValue, dvd, riot;






private DatabaseReference mProposalDatabaseReference;

FirebaseAuth mAuth;
private String imagelogbookUrl;

ScrollView ScrollViewLayout;
LinearLayout PeriodOfInsuranceLayout,ExtraLayout, ProposalLayout1,
        FillProposalLayout, PersonalDetailsLayout,nameOfProposerLayout,
IDPassPortLayout, PinNoLayout,  mobileLayout,  DrivingLicenseTimeLayout
        , typeOfCoverageLayout, VehicleDetailsLayout, VehicleRegLayout, makeLayout,
        modelLayout, EstimateLayout, AttachCertLayout,
 OwnershipAttachCertLayout,
UseOfVehicle, UseYesLayout, WindscreenLayout,
CassetteLayout, RiotLayout,typeOfVehicleLayout,  marketValueLayout, premiumRateLayout, sumInsuredLayout,
        basicPremiumLayout, trainingLevyLayout, policyHoldersLayout, stampDutyLayout, totalPremiumLayout;

EditText etFrom, etTo, etFirstNameOfProposer, etSurnameProposer, etLastNameProposer, etPassportNo, etPinNo
         , etMobile, etEmail, etDrivingTime,  etVehicelReg,
 etEstimate,  etLimitWindscreen, etLimitDvd, etLimitRiot, etLimitTerrorism, etLimitExcessProtect;

CustomTextView tvPeriodOfInsurance, tvFillProposal, tvPersonalDetails,  tvPinNo,
         tvMobile, tvEmail,  tvDrivingTime,  tvTypeOfCoverage, tvVehicleDetails
        ,tvVehicleReg, tvMake, tvModel,  tvEstimate, tvAttachCert,
  tvExtraBenefits, tvWish, tvWindscreen,
tvDvd, tvRiot, tvTerrorism, tvExcessProtect,tvTypeOfVehicle,  tvMarketValue, tvPremiumRate, tvSumInsured, tvBasicPremium,
        tvTrainingLevy, tvPolicyHolders,tvStampDuty, tvTotalPremium;

Spinner spTypeOfCoverage, spMake, spModel, spUseOfVehicle, spinnerModelYear;

CheckBox cbExcessProtect, cbTerrorism, cbWindscreen, cbDvd,cbRiot;

ImageView ivLogBook, etAttachCert, etOwnershipAttachCert, ivDropPersonal, ivPersonPullUp, ivVehicleDrop, ivVehiclePullUp, ivDropExtra, ivExtraPullUp;
Button bSubmit, bOwnershipAttachCert;
TextView tvBasicInformation, tvPremium, etSumInsured, etBasicPremium, etTrainingLevy, etPolicyHolders,
        etStampDuty, etTotalPremium;

ArrayList<String> TypeOfCoverage = new ArrayList<>();

ArrayAdapter TypeOfCoverageAdapter;
ArrayAdapter yearAdapter;

ArrayList<String> Make = new ArrayList<>();
ArrayList<String> Year = new ArrayList<>();
ArrayList<String> subaruCars = new ArrayList<>();
ArrayList<String> toyotaCars = new ArrayList<String>();
ArrayList<String> nissanCars = new ArrayList<String>();
ArrayList<String> mercedesBenzCars = new ArrayList<String>();
ArrayList<String> BMWCars = new ArrayList<String>();
ArrayList<String> audiCars = new ArrayList<String>();
ArrayList<String> landRoverCars = new ArrayList<String>();
ArrayList<String> hondaCars = new ArrayList<String>();
ArrayList<String> mazdaCars = new ArrayList<String>();
ArrayList<String> mitsubishiCars = new ArrayList<String>();
ArrayList<String> peugeotCars = new ArrayList<String>();
ArrayList<String> isuzuCars = new ArrayList<String>();
ArrayList<String> volkswagenCars = new ArrayList<String>();

ArrayAdapter MakeAdapter, subaruCarsAdapter, toyotaCarsAdapter, nissanCarsAdapter, mercedesBenzCarsAdapter,
        BMWCarsAdapter, audiCarsAdapter,landRoverCarsAdapter, hondaCarsAdapter, mazdaCarsAdapter, mitsubishiCarsAdapter,
        peugeotCarsAdapter, isuzuCarsAdapter, volkswagenCarsAdapter;

ArrayList<String> useOfVehicle = new ArrayList<>();
  ArrayAdapter useOfVehicleAdapter;

FirebaseStorage firebaseStorage;
StorageReference storageReference;

DatabaseReference mProposalInformation;

String proposalId = "";

ProposalDetails currentProposer;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_proposal_form1);
    Toolbar toolbar = (Toolbar) findViewById(hushtagstudios.com.towme.R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

     mProposalInformation = FirebaseDatabase.getInstance().getReference("proposal");

    firebaseStorage = FirebaseStorage.getInstance();
    storageReference = firebaseStorage.getReference();

    cbWindscreen = (CheckBox) findViewById(R.id.cbWindscreen);
    cbWindscreen.setOnClickListener(this);
    cbRiot = (CheckBox) findViewById(R.id.cbRiot);
    cbRiot.setOnClickListener(this);
    cbDvd = (CheckBox) findViewById(R.id.cbDvd);
    cbDvd.setOnClickListener(this);
    cbExcessProtect = (CheckBox) findViewById(R.id.cbExcessProtect);
    cbExcessProtect.setOnClickListener(this);
    cbTerrorism = (CheckBox) findViewById(R.id.cbTerrorism);
    cbTerrorism.setOnClickListener(this);

    ScrollViewLayout = (ScrollView)findViewById(R.id.ScrollViewLayout);
    bSubmit = (Button)findViewById(R.id.bSubimt);
    bSubmit.setOnClickListener(this);
    etFirstNameOfProposer = (EditText)findViewById(R.id.etFirstNameOfProposer);
    etSurnameProposer = (EditText)findViewById(R.id.etSurnameProposer);
    etLastNameProposer = (EditText)findViewById(R.id.etLastNameProposer);
    etPassportNo = (EditText)findViewById(R.id.etPassportNo);
    etPinNo = (EditText)findViewById(R.id.etPinNo);
    etMobile = (EditText)findViewById(R.id.etMobile);
    etEmail = (EditText)findViewById(R.id.etEmail);
    etDrivingTime = (EditText)findViewById(R.id.etDrivingTime);
    etVehicelReg = (EditText)findViewById(R.id.etVehicleReg);

    etEstimate = (EditText)findViewById(R.id.etEstimate);
    etLimitWindscreen = (EditText)findViewById(R.id.etLimitWindscreen);
    etLimitDvd = (EditText)findViewById(R.id.etLimitDvd);
    etLimitExcessProtect = (EditText)findViewById(R.id.etLimitExcessProtect);
    etLimitTerrorism = (EditText)findViewById(R.id.etLimitTerrorism);
    etLimitRiot = (EditText)findViewById(R.id.etLimitRiot);
    etFrom = (EditText)findViewById(R.id.etFrom);
    etFrom.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(DATE_DIALOG_ID);
        }
    });
    etTo = (EditText)findViewById(R.id.etTo);
    etTo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(DATE_DIALOG_ID);
        }
    });

    tvDvd = (CustomTextView)findViewById(R.id.tvDvdSystem);
    tvRiot = (CustomTextView)findViewById(R.id.tvRiot);
    tvExcessProtect = (CustomTextView)findViewById(R.id.tvExcessProtect);
    tvTerrorism = (CustomTextView)findViewById(R.id.tvTerrorism);


    typeOfVehicleLayout = (LinearLayout)findViewById(R.id.typeOfVehicleLayout);
    typeOfCoverageLayout = (LinearLayout)findViewById(R.id.typeOfCoverageLayout);
    marketValueLayout = (LinearLayout)findViewById(R.id.marketValueLayout);
    premiumRateLayout = (LinearLayout)findViewById(R.id.premiumRateLayout);
    sumInsuredLayout = (LinearLayout)findViewById(R.id.sumInsuredLayout);
    basicPremiumLayout = (LinearLayout) findViewById(R.id.basicPremiumLayout);
    trainingLevyLayout = (LinearLayout)findViewById(R.id.trainingLevyLayout);
    policyHoldersLayout = (LinearLayout)findViewById(R.id.policyHoldersLayout);
    stampDutyLayout = (LinearLayout)findViewById(R.id.stampDutyLayout);
    totalPremiumLayout = (LinearLayout)findViewById(R.id.totalPremiumLayout);
    tvBasicInformation = (TextView)findViewById(R.id.tvBasicInformation);
    tvPremium = (TextView)findViewById(R.id.tvPremium);
    tvTypeOfVehicle = (CustomTextView)findViewById(R.id.tvTypeOfVehicle);
    tvTypeOfCoverage = (CustomTextView)findViewById(R.id.tvTypeOfCoverage);
    tvMarketValue = (CustomTextView)findViewById(R.id.tvMarketValue);
    tvPremiumRate = (CustomTextView)findViewById(R.id.tvPremiumRate);
    tvSumInsured = (CustomTextView)findViewById(R.id.tvSumInsured);
    tvBasicPremium = (CustomTextView)findViewById(R.id.tvBasicPremium);
    tvTrainingLevy =(CustomTextView)findViewById(R.id.tvTrainingLevy);
    tvPolicyHolders = (CustomTextView)findViewById(R.id.tvPolicyHolders);
    tvStampDuty = (CustomTextView)findViewById(R.id.tvStampDuty);
    tvTotalPremium = (CustomTextView)findViewById(R.id.tvTotalPremium);
    etBasicPremium = (TextView) findViewById(R.id.etBasicPremium);
    etPolicyHolders = (TextView) findViewById(R.id.etPolicyHolders);
    etStampDuty = (TextView) findViewById(R.id.etStampDuty);
    etSumInsured = (TextView) findViewById(R.id.etSumInsured);
    etTrainingLevy = (TextView) findViewById(R.id.etTrainingLevy);
    etTotalPremium = (TextView) findViewById(R.id.etTotalPremium);

    bOwnershipAttachCert = (Button)findViewById(R.id.bOwnershipAttachCert);
    bOwnershipAttachCert.setOnClickListener(this);


     ivDropPersonal = (ImageView)findViewById(R.id.ivDropPersonal);
    ivDropPersonal.setOnClickListener(this);
     ivPersonPullUp = (ImageView)findViewById(R.id.ivPersonPullUp);
    ivPersonPullUp.setOnClickListener(this);
    ivDropExtra = (ImageView)findViewById(R.id.ivDropExtra);
    ivDropExtra.setOnClickListener(this);
    ivExtraPullUp = (ImageView)findViewById(R.id.ivExtraPullUp);
    ivExtraPullUp.setOnClickListener(this);
    ivVehicleDrop = (ImageView)findViewById(R.id.ivVehicleDrop);
    ivVehicleDrop.setOnClickListener(this);
    ivVehiclePullUp = (ImageView)findViewById(R.id.ivVehiclePullUp);
    ivVehiclePullUp.setOnClickListener(this);


    PersonalDetailsLayout = (LinearLayout)findViewById(R.id.PersonalDetailsLayout);
    VehicleDetailsLayout = (LinearLayout)findViewById(R.id.VehicleDetailsLayout);
    ExtraLayout = (LinearLayout)findViewById(R.id.ExtraLayout);



    ivLogBook = (ImageView)findViewById(R.id.ivLogBook);

    tvPeriodOfInsurance = (CustomTextView)findViewById(R.id.tvPeriodOfInsurance);

    spMake = (Spinner)findViewById(R.id.spMake);
    spTypeOfCoverage = (Spinner)findViewById(R.id.spTypeOfCoverage);
    spModel = (Spinner)findViewById(R.id.spModel);
    spinnerModelYear = (Spinner)findViewById(R.id.spinnerModelYear);


    mAuth = FirebaseAuth.getInstance();

    //Get Proposal Id from intent










}



@Override
public boolean onCreateOptionsMenu(Menu menu){
    //inflate the menu this adds items to the action bar if it is present
    getMenuInflater().inflate(R.menu.proposal_form, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
    if (item.getItemId() ==  android.R.id.home){
        onBackPressed();
    }
    if (item.getItemId() == R.id.edit);{

    }
    if (item.getItemId() == R.id.discardChanges);{

    }
    return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
    Intent openNewInsurance = new Intent(ProposalForm1.this, NewInsurance.class);
    startActivity(openNewInsurance);
    finish();
}
@Override
public boolean onSupportNavigateUp() {
    onBackPressed();
    return true;
}

@Override
public void onClick(View v) {
    switch (v.getId()){
        case R.id.bSubimt:

            fillProposalForm();
            new Database(getBaseContext()).addToCart(new Order(
            proposalId,
                    currentProposer.getFirstNameProposer(),
                    currentProposer.getSurnameProposer(),
                    currentProposer.getLastNameProposer(),
                    currentProposer.getIdNumber(),
                    currentProposer.getVehicleReg(),
                    currentProposer.getTotalPremium()));




            break;


        case R.id.bOwnershipAttachCert:
            break;




        case R.id.cbWindscreen:

            if (cbWindscreen.isChecked()) {
                etLimitWindscreen.setVisibility(View.VISIBLE);
            }
            break;


        case R.id.cbDvd:

            if (cbDvd.isChecked()) {
                etLimitDvd.setVisibility(View.VISIBLE);
            }
            break;


        case R.id.cbRiot:

            if (cbRiot.isChecked()) {
                etLimitRiot.setVisibility(View.VISIBLE);
            }
            break;

        case R.id.cbExcessProtect:

            if (cbExcessProtect.isChecked()) {
                etLimitExcessProtect.setVisibility(View.VISIBLE);
            }
            break;

        case R.id.cbTerrorism:

            if (cbTerrorism.isChecked()) {
                etLimitTerrorism.setVisibility(View.VISIBLE);
            }
            break;

        case R.id.ivDropPersonal:

            ivDropPersonal.setVisibility(View.GONE);
            ivPersonPullUp.setVisibility(View.VISIBLE);
            PersonalDetailsLayout.setVisibility(View.VISIBLE);


            break;

        case R.id.ivPersonPullUp:
            PersonalDetailsLayout.setVisibility(View.GONE);
            ivPersonPullUp.setVisibility(View.GONE);
            ivDropPersonal.setVisibility(View.VISIBLE);


            break;


        case R.id.ivDropExtra:
            ivDropExtra.setVisibility(View.GONE);
            ivExtraPullUp.setVisibility(View.VISIBLE);
            ExtraLayout.setVisibility(View.VISIBLE);


            break;

        case R.id.ivExtraPullUp:

            ExtraLayout.setVisibility(View.GONE);
            ivVehiclePullUp.setVisibility(View.GONE);
            ivDropExtra.setVisibility(View.VISIBLE);

            break;

        case R.id.ivVehicleDrop:

            ivVehicleDrop.setVisibility(View.GONE);
            ivVehiclePullUp.setVisibility(View.VISIBLE);
            VehicleDetailsLayout.setVisibility(View.VISIBLE);

            break;

        case R.id.ivVehiclePullUp:

            ivVehiclePullUp.setVisibility(View.GONE);
            ivVehicleDrop.setVisibility(View.VISIBLE);
            VehicleDetailsLayout.setVisibility(View.GONE);




            break;



    }

}

private void fillProposalForm() {


    if (etFirstNameOfProposer.getText().toString().isEmpty()){
        etFirstNameOfProposer.setError("First name cannot be empty");
    } else if (etSurnameProposer.getText().toString().isEmpty()){
        etSurnameProposer.setError("Surname cannot be empty");
    } else if (etLastNameProposer.getText().toString().isEmpty()){
        etLastNameProposer.setError("Last name cannot be empty");
    } else if (etPassportNo.getText().toString().isEmpty()){
        etPassportNo.setError("ID/Passport number cannot be empty");
    } else if (etPinNo.getText().toString().isEmpty()){
        etPinNo.setError("KRA pin number cannot be empty");

    }else if (etMobile.getText().toString().isEmpty()){
        etMobile.setError("Mobile number cannot be empty");
    }else if (etEmail.getText().toString().isEmpty()){
        etEmail.setError("Email cannot be empty");


    } else if (etDrivingTime.getText().toString().isEmpty()){
        etDrivingTime.setError("Driving time duration cannot be empty");

    } else if (etFrom.getText().toString().isEmpty()){
        etFrom.setError("Period of insurance start cannot be empty");
    } else if (etTo.getText().toString().isEmpty()){
        etTo.setError("Period to insurance end cannot be empty");
    } else if (etVehicelReg.getText().toString().isEmpty()){
        etVehicelReg.setError("Vehicle registration cannot be empty");

    } else if (etEstimate.getText().toString().isEmpty()){
        etEstimate.setError("The present estimated value of vehicle cannot be empty");

    } else if (!Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()){
        etEmail.setError("Invalid email address");
    }


     firstNameProposer = etFirstNameOfProposer.getText().toString();
     lastNameProposer = etLastNameProposer.getText().toString();
     surnameProposer = etSurnameProposer.getText().toString();
     idNumber = etPassportNo.getText().toString();
     pinNo = etPinNo.getText().toString();
     email = etEmail.getText().toString();
     mobile = etMobile.getText().toString();
     drivingTime = etDrivingTime.getText().toString();

     PeriodFrom = etFrom.getText().toString();
     PeriodTo = etTo.getText().toString();


     vehicleReg  = etVehicelReg.getText().toString();

    marketValue = etEstimate.getText().toString();



    spTypeOfCoverage.setAdapter(TypeOfCoverageAdapter);
    spTypeOfCoverage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
             typeOfCoverage = spTypeOfCoverage.getItemAtPosition(position).toString();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });


     windscreenValue = etLimitWindscreen.getText().toString();
     dvd = etLimitDvd.getText().toString();
     riot = etLimitRiot.getText().toString();
     excessProtector = etLimitExcessProtect.getText().toString();
     terrorism = etLimitTerrorism.getText().toString();
     basicPremium = etBasicPremium.getText().toString();
     trainingLevy = etTrainingLevy.getText().toString();
     policyHolders = etPolicyHolders.getText().toString();
     stampDuty = etStampDuty.getText().toString();
     totalPremium = etTotalPremium.getText().toString();

     currentProposer = new ProposalDetails( firstNameProposer
            ,lastNameProposer,surnameProposer, idNumber, pinNo,
            email, mobile, drivingTime, PeriodFrom, PeriodTo, vehicleReg,
            marketValue, typeOfCoverage, vehicleMake, vehicleModel,
            yearOfManf, windscreenValue, dvd, riot,
            excessProtector, terrorism, basicPremium, trainingLevy,
            policyHolders, stampDuty, totalPremium);



    mProposalInformation.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
            .setValue(currentProposer);




    final AlertDialog waitingDialog = new SpotsDialog(ProposalForm1.this,"Loading",R.style.Custom);
    waitingDialog.show();



    startActivity(new Intent(ProposalForm1.this,Cart.class));

}




}

2 个答案:

答案 0 :(得分:2)

你要

java.lang.NumberFormatException: For input string: ""

这意味着您正在尝试将空字符串转换为整数

中的order.getTotalPremium()order.getProposalId()为空
total+=(Integer.parseInt(order.getTotalPremium()))* (Integer.parseInt(order.getProposalId()));

在日志中打印并调试它们。

答案 1 :(得分:0)

可能这些order.getTotalPremium()或order.getProposalId()返回空字符串 所以请检查以下代码

JOIN