Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to load image that are retrieve from database when i scroll down to bottom in Xamarin.android?

GASRONGASRON Member ✭✭
edited August 2020 in Xamarin.Android

I want to load the last 10 images from the phpMyAdmin database after when I scroll down to the bottom Of the screen it wants to load another 10 image that is above to the last 10 images from the database in xamarin.Android. And I'm newbie please help me guys

Answers

  • YelinzhYelinzh Member, Xamarin Team Xamurai

    How to load image that are retrieve from database when i scroll down to bottom

    What control do you want to detect the scrolling? ListView? If so, try to detect the Scroll event of the listView to check the scroll position.

    Check the code:

    listview.Scroll += scrollMethod;
    ...
    
    bool isLoading;
    private void scrollMethod(object sender, ScrollEventArgs e)
    {
        if (!isLoading&& ((e.FirstVisibleItem + e.VisibleItemCount) >= (e.TotalItemCount)))
        {
            isLoading = true;
    
            //update the data
            LoadData();
        }
    }
    
    public void LoadData()
    {
        //get the images from database and add to the data list
        dataList.addAll(newItems);
        adapter.notifyDataSetChanged();
        isLoading = false;
    }
    

    Simliar issue:
    https://stackoverflow.com/questions/25350137/check-if-android-listview-is-scrolled-down-to-the-last-item

  • GASRONGASRON Member ✭✭

    I want to retrieve the 10 images from the database and I want to show it in my list view when the scroll touch the bottom

  • YelinzhYelinzh Member, Xamarin Team Xamurai

    Try to detect the Scrolled event of the listView, check the posted code above.

  • GASRONGASRON Member ✭✭

    how to toast when listview scroll touch the bottom screen?

  • ExoskeletorExoskeletor Member ✭✭✭

    @GASRON said:
    how to toast when listview scroll touch the bottom screen?

    You mean when you dont have any other items to load or indeed when the scroll touch the bottom? if you check the @YelinZh code, LoadData(); only happens when you are in the bottom end of the scroll

Sign In or Register to comment.