Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7499565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:52:00+00:00 2026-05-29T19:52:00+00:00

I created a simple button that sets an EditText when clicked. I created another

  • 0

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 if TimerSpin.equals("5 Mins"), 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.

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");
    }

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:52:02+00:00Added an answer on May 29, 2026 at 7:52 pm

    The problem is, you are comparing Spinner to a String which actually should be Spinner‘s selected String to another String..

    correct this by:

    if(TimerSpin.getSelectedItem().toString().equals("5 Mins"))
    {
       // your code...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created this simple code, It it just a button that stays on a
I've created a very simple one-button MFC dialog app that attempts to utilize a
I'm trying to create a simple button that deletes a row from the database.
I wanted to create a page with a simple button which runs away from
I created a simple asp.net form which allow users to view a list of
I've created a simple KML file that works in the standalone Google Earth client,
I've created the following very simple button style: <ControlTemplate x:Key=SimpleButton TargetType={x:Type ButtonBase}> <ContentPresenter x:Name=content
I've created a simple user control which is manually created with something like MyUserControl
I have created a simple application and edited the index.erb file so that I
I have a button with a background-image property that sets 1) an icon for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.