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

  • SEARCH
  • Home
  • 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 9207815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:28:15+00:00 2026-06-18T00:28:15+00:00

I have developed the following for loop to set the data in a drop

  • 0

I have developed the following for loop to set the data in a drop down list. This works perfectly if I use a number on the .get() method to select and compare which item has been clicked, but obviously this is useless with a set integer value.

I’m getting the error that the ‘a’ variable cannot be resolved to a variable.

I’m really not sure why though?

Here’s the code:

List<String> list = new ArrayList<String>();
list.add("-");
list.add("Medical");
list.add("Business");
list.add("Family");
list.add("Other");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
editTime.setAdapter(dataAdapter);

for(int a = 0; a < list.size(); a ++);
{
    // Error on the 'a' variable - cannot be resolved to a variable.    
    if(typeReturned == list.get(a));
    {
        // Error on the 'a' variable - cannot be resolved to a variable.
        editTime.setSelection(a);

    }
}
  • 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-06-18T00:28:16+00:00Added an answer on June 18, 2026 at 12:28 am

    You have an unnecessary semicolon after your for loop:

    for(int a = 0; a < list.size(); a ++);
    

    If you don’t delete it, it is the same as writing:

    for(int a = 0; a < list.size(); a ++) { }
    // a isn't in scope here any more.
    

    You have the same mistake after your if condition. You have to get rid of that semicolon, too.

    Also, I think typeReturned is a String, and you are comparing it with ==. That is a bad idea. You have to use .equals(), if you want to check if both strings have the same content, see:

    How do I compare Strings in Java

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed the following C code to mask data before sending back to
I have developed on EXE project(use for startup task) and use following dlls of
I have developed the following class to retrieve the node-list of a xml document:
In a JSF 2 application, which is developed on tomcat, I have the following
I have some data similar to the following chart: http://developer.yahoo.com/yui/examples/charts/charts-seriescustomization_clean.html Only difference is that
I am following this tutorial https://developer.android.com/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually
I'm following this MVC model: http://java.sun.com/developer/technicalArticles/javase/mvc/ In my model I have an ArrayList shapes
I have developed sample api as jar file. This jar file contains the code
I have the following loop that adds an object to an array if certain
I have developed a Loadable Kernel Module (LKM) for android. I use kzalloc :

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.