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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:13:04+00:00 2026-06-19T03:13:04+00:00

I have a array of cities – String[] cities = { Riyadh, Jubail, Jeddah,

  • 0

I have a array of cities –

String[] cities = { "Riyadh", "Jubail", "Jeddah", "Madinah",
        "Tabuk","Bangalore","Chennai","Pune" };

I am displaying them in a list that has three textview(fixed) .
This means we are going to display three cities at a time.
Here is the method to display the cities.

void setUpCityList(int iCity) {
    tvOneCity.setText(cities[iCity]);
    tvTwoCity.setText(cities[iCity + 1]);
    tvThreeCity.setText(cities[iCity + 2]);
}

When the user swipes up ,i am incrementing the index and the user swipes down i am decrementing the index.

void swipeUp()
{
    iCity++;
    setUpCityList(iCity);
}

void swipeDown()
{
    iCity--;
    setUpCityList(iCity);
}

I want to give this list a endless scroll functionality .
That means if the user swipes up – and list reaches the last three elements , it should again start from first element.

Example –
1. Current display – Last three elements – “Bangalore”,”Chennai”,”Pune”

2. Swipe up — Display should be – Chennai , Pune , Riyadh

How can i achieve this functionality .
This is more of a programming question .
Any Help will be highly appreciated.

  • 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-19T03:13:05+00:00Added an answer on June 19, 2026 at 3:13 am

    You just need to change the indexing in your method:

    void setUpCityList(int iCity) {
        int length = cities.length;   
    
        tvOneCity.setText(cities[iCity % length]);
        tvTwoCity.setText(cities[(iCity + 1) % length]);
        tvThreeCity.setText(cities[(iCity + 2) % length]);
    }
    

    Once the iCity or iCity + 1, etc, reaches the length, actual index will automatically become 0. And for values less than length, it will behave normally, as if there was no modulus operator.

    This way you can create a cycle of as much item you want. So, it’s a generalized and extensible solution.

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

Sidebar

Related Questions

I have mutiple arrays say for now 2, first array has Cities(Mumbai, Pune. Bangalore,
I have a UITableView displaying a list of Cities. I want to separate them
I have a static string array of Cities, States, Categories, etc that is accessed
I have an array of cities and ID's looking like: Brønderslev|810,Frederikshavn|813,Hjørring|860,Jammerbugt|849,Læsø|825,Mariagerfjord|846,Morsø|773,Rebild|840,Thisted|787,Vesthimmerland|820,Aalborg|851 I do not
I have array of strings, String[] data and it's 10 elements has value P
Hi have an array of cities and want to create a google map using
I have a PHP Array of Cities and States. I want the end result
I have an array $suggested_cities , here it is vardumped: array(3) { [15526]=> string(9)
Per PDO's fetchAll() method, I have a two-dimensional array of cities from my database
Possible Duplicate: std::vector<std::string> to char* array I have to call a c function that

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.