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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:34:08+00:00 2026-05-23T03:34:08+00:00

I have an array like this that defines the entry values for a ListPreference:

  • 0

I have an array like this that defines the entry values for a ListPreference:

<string-array name="sortSelectionEntryValues">
<item>0</item>
<item>1</item> 
</string-array>

Now instead of using 0 and 1 in XML, I want to use Java constants like e.g. ORDER_ASC and ORDER_DESC, because later I will access the value of the selected ListPreference entry programmatically and I have to check the value in code, but comparing the value to a well named constant makes code easier to read.

So what I want is something like that:

In Java:
class MyOrderClass
{
    public static final String ORDER_ASC="0";
    public static final String ORDER_DESC="1";
}

In the XML:
<string-array name="sortSelectionEntryValues">
<item>MyOrderClass.ORDER_ASC</item>
<item>MyOrderClass.ORDER_DESC</item> 
</string-array>

Is that somehow possible? Thanks for any hint!

(Please note, the ordering is just a dumb example, I just need to know how to integrate Java constants into the XML definition of an array)

  • 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-23T03:34:09+00:00Added an answer on May 23, 2026 at 3:34 am

    That’s not possible. That said, you will never have to compare “0” to anything. You will likely use if(MyOrderClass.ORDER_ASC.equals(<selected item from list>){..} so it shouldn’t be an issue.

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

Sidebar

Related Questions

Lets say I have an array like this: string [] Filelist = ... I
When you have an array like this: int foo[3][2][2]; and you make: int *bar
I need to move backwards through an array, so I have code like this:
I'm creating my own JavaScript Array-like object and I have methods that call closures.
I have a 2D bitmap-like array of let's say 500*500 values. I'm trying to
I have byte array as input. I would like to convert that array to
I have a 2 dimensional array, like so: char[,] str = new char[2,50]; Now,
I have a one-dimensional array of strings in JavaScript that I'd like to turn
I have a byte array in memory, read from a file. I would like
If you have something like: val myStuff = Array(Person(joe,40), Person(mary, 35)) How do you

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.