Note that there are some explanatory texts on larger screens.

plurals
  1. POButton and Button + CheckBox
    primarykey
    data
    text
    <p>Hello I do have a question about the Android CheckBox =)</p> <p>I do want to accomplish that if i press my reset button a TextView will clear its content. This TextView also writes the content into a file. </p> <p>If i tick my CheckBox and then press the Button the same thing happends but it should also delete the content from the file or just delete the file. -> to eliminate entries of older sessions which will be loaded otherwise.</p> <pre><code>//global CheckBox mCheckFileDelete; //setupWidgets() which is called by onCreate() mCheckFileDelete = (CheckBox)findViewById(R.id.cBdeleteFile); //onClick (View view) if (view.getId()==R.id.btn2reset &amp;&amp; mCheckFileDelete.isChecked()) { mMypoints.setText(null); mErgebnis.setText(null); setImage(5); mNotenHistory.setText(""); //Delete File File f = new File(getFilesDir(), FILENAME); f.delete(); } else { mMypoints.setText(null); mErgebnis.setText(null); setImage(5); mNotenHistory.setText("0"); } </code></pre> <p>Hope someone can give me hint. Is it really necessary to asign a seperate method to handle the whole isChecked() thing like the developer.android article shows? Besides that i do not now how to implement this in my case.</p> <p>Kind regards</p> <p>//EDIT regarding a Question MainActivity.onClick(View view)</p> <pre><code>Button berechne = (Button) findViewById(R.id.btn1calc); Button reset = (Button) findViewById(R.id.btn2reset); berechne.setOnClickListener(this); reset.setOnClickListener(this); @Override public void onClick(View view) { if (view.getId()==R.id.btn1calc) { //int ka_counter = 1; double mypoints = Double.valueOf(String.valueOf(mMypoints.getText())); String spinner_maxpoints_string = mMaxPoints_spin.getSelectedItem().toString(); double spinner_maxToDouble = Double.valueOf(String.valueOf(spinner_maxpoints_string)); double note = (6-(5*(mypoints/spinner_maxToDouble))); double note_rounded = Math.round(note*100)/100.0; String string_note = String.valueOf(note_rounded); mErgebnis.setText(string_note); if (string_note == null) { setImage(0); } else { if(note_rounded &gt;= 1.0 &amp;&amp; note_rounded &lt;= 1.4) { setImage(1); } else { if (note_rounded &gt;= 1.5 &amp;&amp; note_rounded &lt;= 1.9 ) { setImage(2); } else { if (note_rounded &gt;= 2.0 &amp;&amp; note_rounded &lt;= 2.5) { setImage(3); } else { if (note_rounded &gt;= 2.6 &amp;&amp; note_rounded &lt;= 3.2) { setImage(4); } else { if(note_rounded &gt;= 3.3 &amp;&amp; note_rounded &lt;= 4.0) { setImage(5); } else { if(note_rounded &gt;= 4.1 &amp;&amp; note_rounded &lt;= 4.9) { setImage(6); } else { if(note_rounded &gt;= 5.0 &amp;&amp; note_rounded &lt;= 6.0) { setImage(7); } } } } } } } } //ka_counter = ka_counter +1; //mNotenHistory.setText("KA " + ka_counter +": " + string_note + "\n" + mNotenHistory.getText().toString()); mNotenHistory.setText(string_note + "\n" + mNotenHistory.getText().toString()); try { FileOutputStream fo = openFileOutput(FILENAME, Context.MODE_APPEND); fo.write(string_note.getBytes()); fo.write("\n".getBytes()); fo.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } if (view.getId()==R.id.btn2reset) { if(mCheckFileDelete.isChecked()) { mMypoints.setText(null); mErgebnis.setText(null); setImage(0); mNotenHistory.setText(""); //Delete File File f = new File(getFilesDir(), FILENAME); f.delete(); } else { mMypoints.setText(null); mErgebnis.setText(null); setImage(0); mNotenHistory.setText("0"); } } } </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