Why can't I use an int from a spinner in the same class?
<p>Ok so I am working on an android app and I have implanted spinners... I have a total of four spinners and I have learned that if the spinner reads the options from the strings it has a defined number for the selection(i.e the first option is "0" next is "1" and so on)</p>

<p>I have the following code for the spinner</p>

<pre><code>        Spinner a = (Spinner) findViewById(R.id.spinner1);
    a.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView adapter, View v, int a,
                long lng) {
            // do something here
            Toast.makeText(adapter.getContext(), "You selected: " + a,
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onNothingSelected(AdapterView arg0) {
            // do something else
        }
    });
</code></pre>

<p>and another one but with the int "b"</p>

<p>but later on in the same class I want to use some maths to get e=a,b (i.e if a=6 and b=5 e=65, or a=4 and b=3 e=43)
This is easily done by executing </p>

<pre><code>int e=a*10+b;
</code></pre>

<p>The problem is I want to display this when you press a button, so I have the following code</p>

<pre><code>public void Calc(View v) {
    int e = a * 10 + b;
    Toast.makeText(this, "Value: " + e, Toast.LENGTH_LONG).show();
}
</code></pre>

<p>but results in the error ""a" &amp; "b" cannot be resolved to a variable"
why is this and how can I create a button that will be able to read these variables?</p>
