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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:49:40+00:00 2026-06-12T09:49:40+00:00

I am looking for a guide as to how i can implement switch that

  • 0

I am looking for a guide as to how i can implement switch that would get values from a string array. Basically, i have a spinner with all the items as stated in my array, so i want to implement a switch so that whenever i click on an item, it will trigger an event, for example, going to another activity.

<string-array name="location1">

    <item>string a</item>
    <item>string a</item>
    <item>string b</item>
    <item>string c</item>
    <item>string d</item>

</string-array>

So, if i have a string array like this, how should I implement my switch statement?

  • 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-12T09:49:41+00:00Added an answer on June 12, 2026 at 9:49 am

    If array is:

    <string-array name="cars_array">
        <item>Audi</item>
        <item>Ferrari</item>
    </string-array>
    

    You can access them like this:

    Resources res = getResources();
    String[] cars = res.getStringArray(R.array.cars_array);
    

    then you can access them individually as cars[0], cars[1] etc

    If you want to access the same string resource as part of an array and individually as well, then you can do this:

    <string name="audi">Audi</string>
    <string name="ferrari">Ferrari</string>
    
    <string-array name="cars_array">
        <item>@string/audi</item>
        <item>@string/ferrari</item>
    </string-array>
    

    Then you can simply say “@string/audi” to get it individually as well as you can use the array name “@string/cars” to use the string array as a whole.

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

Sidebar

Related Questions

looking for a link to the copyright information for android dev guide. I have
Looking at the Android tutorial on: http://developer.android.com/guide/topics/fundamentals/fragments.html ... it seems fragments have their layouts
My ultimate goal is to have a dry base repository that I can override
I am looking to create a site like photofunia.com where basically you can apply
I'm looking for a fast PRNG so that I can quickly create (semi)unique IDs
Ii am looking for a guide and information to specifically reading from and writing
Okay, so I have been looking at the sample code below from the Ephesoft
i have a datagridview row, containing three string values. These values should be looked
Can anyone kindly guide me as to how to implement a dynamic auto complete
I am looking for a tutorial which will guide me to style HTML pages

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.