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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:05:18+00:00 2026-06-11T09:05:18+00:00

Since Android has different size of layout, the number of rows can be shown

  • 0

Since Android has different size of layout, the number of rows can be shown in the ListView is therefore variable, ideally, we need to perform API call like..

http://www.example.com/get_product?count=N&..

Where N = number of rows can be displayed in a given ListView + 10 items buffer for offscreen scrolling effect.

What would be best method to define the value of N in the app?

  • 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-11T09:05:19+00:00Added an answer on June 11, 2026 at 9:05 am

    Try this:

    ListView list = (ListView) findViewById(R.id.list) //R.id.list will be your listview id in the layout    
    int n = Double.intValue(list.getHeight()/list.getChildAt(1).getHeight())
    

    If it doesn’t work because it need to first create the list to get a child, and you have the dp height of the listItem (could be if you use a custom layout), you could use

    ListView list = (ListView) findViewById(R.id.list) //R.id.list will be your listview id in the layout    
    Resources r = getResources();
    int px = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, !!!YOUR LISTITEM HEIGHT IN DP!!!, r.getDisplayMetrics())); //Convert DP to actual size in pixels (rounded)
    int n = Double.intValue(list.getHeight()/px)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When querying Android's MMS-SMS Content Provider , the date column has different epoch time
I need to create a very small ListView. Each row could have a different
I know this has been asked in many different ways but I still can
Since Android SDK 3.0, users can choose to encrypt their entire disk which basically
One of the activities in my Android app has a relative layout with two
My app uses a method that was deprecated since Android 2.1 with a different
I'm sure this has been asked a number of times from various different perspectives,
Ever since Froyo (Android 2.2), Google's Android OS has supported syncing Microsoft Exchange accounts
-webkit-device-pixel-ratio query is supported by both iOS and Android but since iOS does not
Since installing v17 of the android build tools I am getting a VerifyError in

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.