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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:18:50+00:00 2026-05-22T03:18:50+00:00

I have a numeric.xml file in my project’s values directory that holds most of

  • 0

I have a “numeric.xml” file in my project’s “values” directory that holds most of the project’s integer constants. I would like to use some of those constants in a switch statement, but Eclipse/Java does not like that because it does not consider “resources.getInteger(R.integer.INTEGER_NAME)” to be a constant. Is there some way to get the compiler and/or Eclipse to see that it is a constant, or do I just need to live with if/else chains?

Edit: I tried doing “final int INTEGER_NAME = resources.getInteger(R.integer.INTEGER_NAME)” and using INTEGER_NAME in the case statement, but that didn’t work either.

  • 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-22T03:18:51+00:00Added an answer on May 22, 2026 at 3:18 am

    Technically, your integer resource values are not constants. How is the compiler supposed to know the value for each case? There’s always the possibility of retrieving different values for different configurations. (You could, for instance, have a values-land resource folder with different values for landscape.) Or you could just change the values in the xml file.

    If they are truly constants, define them in code. The only other alternative I can see is to create a dispatch table of Runnable (or Callable) objects, one for each branch of the switch, and retrieve the appropriate one based on the value retrieved from the resources.

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

Sidebar

Related Questions

I have the following xml file <Layout xmlns=http://tempuri.org/Layout/> <Numeric Id=temperature Caption=Temperature> <validation:IsValidWhen xmlns:validation=http://tempuri.org/Validation/> </validation:IsValidWhen>
I have a code as such that reads in an xml file into a
I have a numeric vector, it contains patches of elements that are repeating, something
I have a list of numeric values. I may normalize the values if needed.
I have a dataframe with numeric entries like this one test <- data.frame(x =
I have a Python function that takes a numeric argument that must be an
I have a stored procedure that takes an XML parameter and inserts the Entity
I have an application that generates Open XML documents with Content Controls. To create
I have .MAP file which is created from SAS XML mapper. As the name
I have an XML string that gets returned to me, sometimes it is invalid

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.