Note that there are some explanatory texts on larger screens.

plurals
  1. POI am trying to get the value of a string from an if statement to the main class
    primarykey
    data
    text
    <p>I have a bit of code where the user inputs numbers into EditText. </p> <p>Depending on the value of what they enter I want to set a string that gets pulled by a dialog fragment (which I have replaced with a toast for now until I can get the string bit fixed.)</p> <p>I get the pushups input which is changed to an int. That int is compared in the logic below it against certain standards. Depending on where it falls I want it to change a string that will be displayed later once all the logic is done.</p> <pre><code>package com.mynavy; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class PRTC extends Activity { String pushs; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.prtc); Button submit = (Button) findViewById(R.id.submit); submit.setOnClickListener(new OnClickListener() { public void onClick(View v) { EditText age = (EditText) findViewById(R.id.agetxt); EditText pushups = (EditText) findViewById(R.id.pushups); EditText situps = (EditText) findViewById(R.id.situps); EditText runtime = (EditText) findViewById(R.id.runtime); String agetxt = String.valueOf(age.getText().toString()); int agen = Integer.valueOf(agetxt); String pushtxt = String.valueOf(pushups.getText().toString()); int pushn = Integer.valueOf(pushtxt); String sittxt = String.valueOf(situps.getText().toString()); int sitn = Integer.valueOf(sittxt); String runtxt = String.valueOf(runtime.getText().toString()); int runn = Integer.valueOf(runtxt); //CHANGE THESE WHEN NEW INSTRUCTIONS COME OUT!! if (agen &gt;= 17 || agen &lt;=20) { if (pushn &gt;=20 || pushn &lt;=30){ String pushs = "Good"; }else if (pushn &gt;=31 || pushn &lt;=40){ String pushs = "Excellent"; }else if (pushn &gt;=41 || pushn &lt;=50){ String pushs = "Outstanding";}} if (sitn &gt;= 20 || sitn &lt;= 30){ String sits = "Good"; }else if (sitn &gt;= 31 || sitn &lt;=40){ String sits = "Excellent"; }else if (sitn &gt;= 41 || sitn &lt;=50){ String sits = "Outstanding"; Toast.makeText(getBaseContext(), pushs + "Score.", Toast.LENGTH_SHORT).show(); }else{ Toast.makeText(getBaseContext(), "TEST FAILED!!", Toast.LENGTH_SHORT).show(); } };}); }} </code></pre> <p>I know I have been asking a lot lately, but any help that is provided will be immensely appreciated as always!!</p>
    singulars
    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.
 

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