How to get the visible list items count in a Xamarin android Array adapter

Veswanth

I'm currently working on Xamarin android mobile application. There I have a requirement for displaying 50 list items using ArrrayAdapter in a 10-inch mobile screen.

When a mobile screen displays page with list items, It's showing by default 10 items at first. If I scroll further down it is showing items from 5 to 15. And if I scroll further it is showing 11 to 20.

At any given point of time, it is capable of displaying only 10 items.

How can I get the count(In ArrayAdapter GetView method) based on the screen size of the phone (in my case 10)?

Appreciate your help.

Thanks,

Veswanth

jgoldberger - MSFT

On Android the ListView has two properties that should help:

int start = listView.FirstVisiblePosition;
int end = listView.LastVisiblePosition;

So Subtract start from end and add 1 to get the total visible items, e.g.:

int numberOfVisibleItems = end - start + 1;

Note I did not test this, but it should work as long as you do this after the list is fully populated and displayed. Note that if even a sliver of a list item is in view, it will be counted.

EDIT: How to get the listView reference in GetView()

The ViewGroup parent parameter of GetView(...) should be the ListView, so in GetView(...):

 ListView listView = parent as ListView;
 int start = listView.FirstVisiblePosition;
 int end = listView.LastVisiblePosition;
 int numberOfVisibleItems = end - start + 1;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get the items from adapter and store it in list?

From Dev

How to get the position of the last visible item inside an Adapter in Android

From Dev

Get list of items in custom adapter

From Dev

Xamarin - Get adapter's filter count

From Dev

How to get an Array of items contained in a List

From Dev

android custom List Adapter not displaying items

From Dev

Android ListView get current position in visible items

From Dev

How to fill json array items in arraylist in adapter?

From Dev

How to count items in List with ImmutableJS?

From Dev

How to count specific items in array

From Dev

PyQt4: How can I get a list of the visible items of a QlistWidget?

From Dev

How to get checked checkbox count from adapter?

From Dev

Given a list, How to count items in that list?

From Dev

How to count list items grouped by an embedded list

From Dev

Limit number of list view items through array adapter

From Dev

How to count the visible items in a specific field of PivotTable without looping?

From Dev

How to get children of a layout manager that are not yet visible in recyclerview adapter?

From Dev

Get list of items in android activity

From Dev

create a list of cardview based on items count android

From Dev

Get the lowest list count in array

From Dev

Get the lowest list count in array

From Dev

Dynamically add items to list view using custom adapter for Android app

From Dev

Android: Get activity context into array adapter class

From Java

Get visible items in RecyclerView

From Dev

Get the List of Visible Items from a Pivot Field using VBA

From Dev

Android Studio - Cannot Resolve Symbol items in Array Adapter

From Dev

Android ListView show different items than Adapter get

From Dev

Image Adapter Xamarin Android

From Dev

how to count entries in Date Array List on weekly bases in android

Related Related

  1. 1

    How to get the items from adapter and store it in list?

  2. 2

    How to get the position of the last visible item inside an Adapter in Android

  3. 3

    Get list of items in custom adapter

  4. 4

    Xamarin - Get adapter's filter count

  5. 5

    How to get an Array of items contained in a List

  6. 6

    android custom List Adapter not displaying items

  7. 7

    Android ListView get current position in visible items

  8. 8

    How to fill json array items in arraylist in adapter?

  9. 9

    How to count items in List with ImmutableJS?

  10. 10

    How to count specific items in array

  11. 11

    PyQt4: How can I get a list of the visible items of a QlistWidget?

  12. 12

    How to get checked checkbox count from adapter?

  13. 13

    Given a list, How to count items in that list?

  14. 14

    How to count list items grouped by an embedded list

  15. 15

    Limit number of list view items through array adapter

  16. 16

    How to count the visible items in a specific field of PivotTable without looping?

  17. 17

    How to get children of a layout manager that are not yet visible in recyclerview adapter?

  18. 18

    Get list of items in android activity

  19. 19

    create a list of cardview based on items count android

  20. 20

    Get the lowest list count in array

  21. 21

    Get the lowest list count in array

  22. 22

    Dynamically add items to list view using custom adapter for Android app

  23. 23

    Android: Get activity context into array adapter class

  24. 24

    Get visible items in RecyclerView

  25. 25

    Get the List of Visible Items from a Pivot Field using VBA

  26. 26

    Android Studio - Cannot Resolve Symbol items in Array Adapter

  27. 27

    Android ListView show different items than Adapter get

  28. 28

    Image Adapter Xamarin Android

  29. 29

    how to count entries in Date Array List on weekly bases in android

HotTag

Archive