Note that there are some explanatory texts on larger screens.

plurals
  1. POClearing previously entered edittext data automatically on checking a checkbox
    primarykey
    data
    text
    <p>I have 3 checkboxes and 2 edittexts. When the user checks one checkbox and enters data in one edittext calculations take place. If i check another checkbox the edittext values should automatically clear. However the data in the edittexts exist even after i check other checkboxes.I tried finish() which shuts the application. Any idea how can this be achieved without closing the app? </p> <p>Sorry if this question sounds weird. Iam just learning android Thank you.</p> <p>code for my onCheckedChangedListener</p> <pre><code>public void onCheckedChanged(CompoundButton predictionChkView, boolean isPredictionChecked) { // TODO Auto-generated method stub switch(predictionChkView.getId()) { case R.id.chkLastMileage1: isChkLastMileage1=true; chkLastMileage5.setChecked(false); chkLastMileage10.setChecked(false); ETPredictKm.setText(""); ETPredictFuelQty.setText(""); break; case R.id.chkLastMileage5: isChkLastMileage5=true; chkLastMileage1.setChecked(false); chkLastMileage10.setChecked(false); ETPredictKm.setText(""); ETPredictFuelQty.setText(""); break; case R.id.chkLastMileage10: isChkLastMileage10 =true; chkLastMileage1.setChecked(false); chkLastMileage5.setChecked(false); ETPredictKm.setText(""); ETPredictFuelQty.setText(""); break; } } Code for the onFocusChangedListener public void onFocusChange(View predictionFocusView, boolean hasPredictionETFocus) { // TODO Auto-generated method stub FuelStoredInfo predictInfo = new FuelStoredInfo(this); predictInfo.open(); predictInfo.getAvgMileage(this); predictInfo.close(); try { predictKm = Long.parseLong(ETPredictKm.getText().toString()); predictFuetlQty = Double.parseDouble(ETPredictFuelQty.getText().toString()); } catch(NumberFormatException ne) { ne.printStackTrace(); } if(isChkLastMileage1 ==true || isChkLastMileage5==true||isChkLastMileage10==true) { if(ETPredictKm.hasFocus()) { ETPredictKm.setText(""); if(predictFuetlQty!=0) { predictKm =(long) (predictionMileage*predictFuetlQty); //setPredictKm(predictKm); ETPredictKm.setText(String.valueOf(predictKm)); } } else if(ETPredictFuelQty.hasFocus()) { ETPredictFuelQty.setText(""); if(predictKm!=0) { predictFuetlQty =predictKm/predictionMileage; //setPredictFuetlQty(predictFuetlQty); ETPredictFuelQty.setText(new DecimalFormat("##.##").format(predictFuetlQty)); } } } else { Toast.makeText(getApplicationContext(), "Please check a checkbox!", Toast.LENGTH_LONG).show(); } } public void onClick(View v) { // TODO Auto-generated method stub ETPredictKm.setText(""); ETPredictFuelQty.setText(""); chkLastMileage1.setChecked(false); chkLastMileage5.setChecked(false); chkLastMileage10.setChecked(false); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload