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

  • Home
  • SEARCH
  • 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 911791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:16:12+00:00 2026-05-15T17:16:12+00:00

My code works like this to list all items in my String array –

  • 0

My code works like this to list all items in my String array – itemsarray

setListAdapter(new ArrayAdapter<String>(this, R.layout.row,
        R.id.label, itemsarray));

However, I know by this call that I only want to list the first X number of items from itemsarray. How can I load only the first X items form itemsarray into the ListAdapter?

  • 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-15T17:16:13+00:00Added an answer on May 15, 2026 at 5:16 pm

    There’s no way to do it automatically… you will have to do it manually. You have two alternatives:

    // the easy one:
    ArrayList<String> someItems = new ArrayList<String>();
    for(String element : itemsarray) // add the first 5 elements
        someItems.add(element);
    setListAdapter(new ArrayAdapter<String>(this, R.layout.row, R.id.label, someItems));
    

    Or you can create a subclass of ArrayAdapter and override the getCount method returning X. It will make the list think it just have X elements to show.

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

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I had same problem before... here is what I did..… May 17, 2026 at 2:21 am
  • Editorial Team
    Editorial Team added an answer No, in the general case you cannot specify an "exclusion… May 17, 2026 at 2:21 am
  • Editorial Team
    Editorial Team added an answer Found a solution: mysql> UPDATE table SET last_update=now(), last_monitor=last_update WHERE… May 17, 2026 at 2:21 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'd like to be able to create an multidim associative array where one dimension
In some of my code I put a series of objects in a list
I have a simple class called Tuple. which looks like this : class tuple
I have List object filled with instances of a custom struct. list.Add(new Mail(mail1, test11,
I'm trying to parse an array of JSON objects into an array of strings
I'm aggregating RSS feeds using FeedTools. I followed this tutorial: http://simonwoodside.com/weblog/2008/12/7/ruby_on_rails_feedrss_aggregator/ and everything functioned
I've got a simple WPFToolkit DataGrid : <Grid> <dg:DataGrid Name=theDataGrid/> </Grid> And in code
I'm a bit stuck with my code: def setVenueImage(img): img = images.Image(img.read()) x, y
First the code (sorry if its not 100%) I am no expert and then
The All method is supposed to evaluate the argument against all elements in the

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.