Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are SO many problems with this code it's hard to know where to start</p> <p>There are statics you then make duplicate variables for in a method but then try reference outside</p> <p>You're referencing one static from your testfre (which should have a capitcal letter for a name) which you don't mean to be static but you seem to have set to be static because your Calc methods are static</p> <p>you're referencing things from testfre in your calc class that dont'# even exist in testfre</p> <p>it's one insane mess</p> <p>why do you set a keylistener rathen than use on keydown</p> <p>setting text on your edittext that is in your activity from a static class?</p> <p>please give variables proper names not just 1 letter</p> <p>what is Test3_irr and textview6?</p> <p>... more to come</p> <pre><code>public class TestFre extends Activity { private EditText ev; private Spinner em; private Spinner ez; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ev = (EditText) findViewById(R.id.v); em = (Spinner) findViewById(R.id.m); ez = (Spinner) findViewById(R.id.z); } public void onClick(View v) { switch (v.getId()) { case R.id.GO: runCalculateAndSetText(); } } private void runCalculateAndSetText() { String word = ev.getText().toString(); int spinner1pos = em.getSelectedItemPosition(); int spinner2pos = ez.getSelectedItemPosition(); if ("".equals(word)) return; if (spinner1pos &lt; 0) return; if (spinner2pos &lt; 0) return; // run evaluation for Je and populate textview String result = Calc.evaluateJe(word, spinner1pos, spinner2pos); ((TextView) findViewById(R.id.resultJe)).setText(result); // run evaluation for Tu and populate textview String result = Calc.evaluateJe(word, spinner1pos, spinner2pos); ((TextView) findViewById(R.id.resultTu)).setText(result); // run evaluation for Il Elle On and populate textview String result = Calc.evaluateJe(word, spinner1pos, spinner2pos); ((TextView) findViewById(R.id.resultIllElleOn)).setText(result); // Continue for rest of options } } </code></pre> <p>please add</p> <pre><code>onClick="onClick" </code></pre> <p>to your button in the XML (this will call onClick in the activity)</p> <p>Your Calc class should be able to take the word you've typed and the select box index (you seem to be getting the value this relates to from somewhere else) and return you the string to fill the textview</p> <p>The important thing is your Calc class should know NOTHING about your Activity</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