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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:39:17+00:00 2026-05-20T23:39:17+00:00

I need a dynamic string-array. All the examples I have seen show hard-coded string-arrays.

  • 0

I need a dynamic string-array. All the examples I have seen show hard-coded string-arrays. Basically I have a list of years for the user to select. The years are hard coded, but unfortunately current year will not be a relevant choice next year. I don’t want to push updates for this in the future this could be dynamically generated with some kind of system call of the current year + X amount of years in the future for the rest of the list.

I am not sure how to make variables edit the XML, any insight appreciated

Clarification:
I have edited the Res>Values>strings.xml to have a list of years. I manually typed years in the list-item,

it would be:
list-item 2011
list-item 2012
list-item 2013……….

but in the year 2012, older years will not be relevant so I would need this string array regenerated. Is there a way to make the typed years be variables?

such as it would be:
list-item YEAR
list-item YEAR+1
list-item YEAR+2

and a function in the java will let the list know what those values really are, or something

  • 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-20T23:39:18+00:00Added an answer on May 20, 2026 at 11:39 pm

    I’m not sure what the problem is. Perhaps you’re not sure how to do in Java something that you were previously doing in XML?

    Creating an ArrayList of years is simple. This can back a ListView or a Spinner by using an ArrayAdapter.

    ArrayList<Integer> years = new ArrayList<Integer>();
    int thisYear = Calendar.getInstance().get(Calendar.YEAR);
    for (int i = 1990; i <= thisYear; i++) {
        years.add(i);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to wrap a few strings in single quotes for a dynamic TSQL
I need to test a site with a dynamic menu in Mac Firefox, but
Need a way to allow sorting except for last item with in a list.
need ask you about some help. I have web app running in Net 2.0.
I'm clearly missing something here. I need to fill methods of dynamic AS3 class
I want to avoid string concatenation to create dynamic SQL query in SQL 2008.
I need to enumerate all classes in a package and add them to a
In my model I have a string txtSearche with the value coming from a
Let's say I have this: dynamic foo = new Foobar(); And I have this:
I am trying to load a html page through UIWebview.I need to disable all

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.