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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:01:03+00:00 2026-06-02T14:01:03+00:00

@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // TODO

  • 0
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
        int visibleItemCount, int totalItemCount) {
    // TODO Auto-generated method stub
    Toast.makeText(ViewPage.this, "In" , 1).show();
     if (loading) 
     {
         if (totalItemCount > previousTotal) 
         {
            loading = false;
            previousTotal = totalItemCount;
            currentPage++;
         }
     }
     if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) 
     { 


            for(int i=0;i<5;i++)
            {
                filename[i] = contactcursor.getString(contact_column_index);
                Toast.makeText(ViewPage.this, filename[i] +" "+ contactcursor.getString(contact_column_index) , 1).show();
                contactcursor.moveToNext();

            }


            arr_ad = new ArrayAdapter<String>(ViewPage.this, android.R.layout.simple_list_item_1, filename);


            setListAdapter(arr_ad);
            // I load the next page of gigs using a background task,
            // but you can call any function here.
           // new LoadGigsTask().execute(currentPage + 1);
            loading = true;
            Toast.makeText(ViewPage.this,totalItemCount+" "+visibleItemCount+" "+firstVisibleItem+" "+visibleThreshold+" ", 1).show();
     }
}

this is part of the code, where the onScroll should have worked only when listview was scrolled down, but it works automatically when activity starts as the toast within it is printed. thanx in advance.

  • 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-02T14:01:09+00:00Added an answer on June 2, 2026 at 2:01 pm

    First, you dont need to put toast in onScroll because its just not a good idea. Instead use Log.

    Second, its called automatically because Listview needs to populate items inside. So when the ListView insert items for the first time, the scroll element is changed/updated too, causing onScroll to occur (i guess). Once the required amount of items are inserted to fill the Listview visible on screen, I think it will not raise onScroll. So its not a big issue.

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

Sidebar

Related Questions

button3.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub
@Override public void onCancel() { // TODO Auto-generated method stub ERROR:The method onCancel() of
setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { // TODO Auto-generated
listView.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> parent, View viewItem, int position, long arg3) {
mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View item, int position, long id)
In facebook tutorials I see this sample code: @Override public void onActivityResult(int requestCode, int
In Activity we have method @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); //... } My
@Override public void onClick(View v) { if(v.getId()==R.id.cvp11 && v.getId()==R.id.cvp22 && v.getId()==R.id.cvp32) yc.start(); else if(v.getId()==R.id.cvp12
When running my @Override public void updateScene(int x, int y) The code the runs
Source: listener = new PhoneStateListener() { @Override public void onCallStateChanged(int state, String incomingNumber) {

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.