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 6956929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:56:00+00:00 2026-05-27T14:56:00+00:00

I have a spinner. Now I want to compare the variable from the spinner

  • 0

I have a spinner. Now I want to compare the variable from the spinner in a if statement. And than I want to change a variable, but I can’t get the variable changed.
Here is the code from my spinner:

<resources>
<string name="app_name">Groep kiezer</string>
<string name="Mijngroep">Selecteer jouw groep</string>  
<string name="groep1">Admiraal kruysgroep</string>      
<string name="groep2">Admiraal van Kinsbergen</string>  
<string name="groep3">Alexandergroep</string>  
<string name="groep4">Anthonie van diemenstam</string>  
</resources>

And here is the file (a simple rss reader) in witch it’s compared:

public class RSSReaderscoutingnl extends Activity implements OnItemClickListener{
public final String tag = "RSSReaderscoutingnl";
private RSSFeed feed = null;
private String RSSFEEDOFCHOICE;

/** Called when the activity is first created. */

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);

        final Spinner feedbackSpinner = (Spinner)    
findViewById(R.id.SpinnerFeedbackType);  
        final String groep = feedbackSpinner.getSelectedItem().toString();  

        if (groep.equals("groep1")) {
            RSSFEEDOFCHOICE = "http://www.scout.org/rss/feed/all";
        }
        else if (groep.equals("groep2")) {
            RSSFEEDOFCHOICE = "http://www.scout.org/rss/feed/all";
        }
        else if (groep.equals("groep3")) {
            RSSFEEDOFCHOICE = "http://www.scout.org/rss/feed/all";
        }
        else if (groep.equals("groep4")) {
            RSSFEEDOFCHOICE = "http://www.scout.org/rss/feed/all";
    }

    // get rss feed!
    feed = getFeed(RSSFEEDOFCHOICE);

    UpdateDisplay();
        }

private RSSFeed getFeed(String urlToRssFeed)
{
    try
    {
        // setup the url
       URL url = new URL(urlToRssFeed);

       // create the factory
       SAXParserFactory factory = SAXParserFactory.newInstance();
       // create a parser
       SAXParser parser = factory.newSAXParser();

       // create the reader (scanner)
       XMLReader xmlreader = parser.getXMLReader();
       // instantiate our handler
       RSSHandler theRssHandler = new RSSHandler();
       // assign our handler
       xmlreader.setContentHandler(theRssHandler);
       // get our data via the url class
       InputSource is = new InputSource(url.openStream());
       // perform the synchronous parse           
       xmlreader.parse(is);
       // get the results - should be a fully populated RSSFeed instance, or null on error
       return theRssHandler.getFeed();
    }
    catch (Exception ee)
    {
        // if we have a problem, simply return null
        return null;
    }
}

private void UpdateDisplay()
{
    TextView feedtitle = (TextView) findViewById(R.id.feedtitle);
    TextView feedpubdate = (TextView) findViewById(R.id.feedpubdate);
    ListView itemlist = (ListView) findViewById(R.id.itemlist);


    if (feed == null)
    {
        feedtitle.setText("No RSS Feed Available");
        return;
    }

    feedtitle.setText(feed.getTitle());
    feedpubdate.setText(feed.getPubDate());

    ArrayAdapter<RSSItem> adapter = new ArrayAdapter<RSSItem>  
(this,android.R.layout.simple_list_item_1,feed.getAllItems());

    itemlist.setAdapter(adapter);

    itemlist.setOnItemClickListener(this);

    itemlist.setSelection(0);

}


 public void onItemClick(AdapterView parent, View v, int position, long id)
 {
     Log.i(tag,"item clicked! [" + feed.getItem(position).getTitle() + "]");

     Intent itemintent = new Intent(this,ShowDescription.class);

     Bundle b = new Bundle();
     b.putString("title", feed.getItem(position).getTitle());
     b.putString("description", feed.getItem(position).getDescription());
     b.putString("link", feed.getItem(position).getLink());
     b.putString("pubdate", feed.getItem(position).getPubDate());

     itemintent.putExtra("android.intent.extra.INTENT", b);

     startActivityForResult(itemintent,0);
 }

}

I just can’t get it to change RSSFEEDOFCHOICE. I hope someone can help me out.

  • 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-27T14:56:00+00:00Added an answer on May 27, 2026 at 2:56 pm

    Call getSelectedItemId and compare it with the id, not the string:

    switch(feedbackSpinner.getSelectedItemId()) {
    // edit: forgot this one                  ^
        case R.string.groep1:
        case R.string.groep2:
        case R.string.groep3:
        case R.string.groep4:
            RSSFEEDOFCHOICE = "http://www.scout.org/rss/feed/all";
            break;
        default:
            break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two spinner in my system. Now I have to change the selected
I have created a nice scientific calculator and now want to save inputs and
I have a spinner and when the user selects I want to call another
I need to create a spinner from a string. Until now I use an
I have 2 spinner, each spinner's data loaded from database using AsyncTask i call
I'm trying to get an onClickListener to fire on a Spinner, but I get
I have a spinner that is created using the resource file statically. now i
In my app, I have a Spinner , that can be filled with two
Here's the setup. I have a spinner, and each item in the spinner is
I have a spinner widget and I want to populate some data when user

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.