Checking String Array in Android
<p>I created a simple button that sets an EditText when clicked. I created another method called GetTime() which should check a spinner for a string, and then set an Time variable. Then my onClick() just sets the EditText to the value of Time. Its very simple code. The problem is when I do <code>if TimerSpin.equals("5 Mins")</code>, it never changes the value of time. It's still 0. So I'm not sure if my spinner is being checked correctly. But it prints values to the EditText just fine. The spinner is just a StringArray I created in my Strings.xml.</p>

<pre><code>package com.Alan.Gym_Rat;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.view.*;
import android.view.View.OnClickListener;

public class MainScreen extends Activity implements OnClickListener
{
int Calories = 0;
int Time = 0;
EditText CalText;
Button Calculate;
Spinner TimerSpin;
Spinner ExerSpin;

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainmenu);

    TextView MainTitle = (TextView) findViewById(R.id.Title);  
    Typeface Molot = Typeface.createFromAsset(getAssets(), "Molot.otf"); 
    MainTitle.setTypeface(Molot);

    ExerSpin = (Spinner)findViewById(R.id.ExerciseSpin);
    TimerSpin = (Spinner)findViewById(R.id.TimeSpin);

    Calculate =(Button)findViewById(R.id.Calc);
    CalText = (EditText)findViewById(R.id.CalcText);

    Calculate.setOnClickListener((OnClickListener)this);

}
public void GetTime()
{
    if(TimerSpin.equals("5 Mins"))
    {
        Time = 5;
    }
    else
    {
        Time = 0;
    }
}

public void onClick(View v) 
{
    if(v.getId() == R.id.Calc)
    {
        GetTime();
        CalText.setText(Time + " Calories");
    }

}
}
</code></pre>
