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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:54:26+00:00 2026-05-23T04:54:26+00:00

I am developing an app where I need to show some list view control.

  • 0

I am developing an app where I need to show some list view control. I am just implementing the OnScrollListener in my activity in order to monitor my listview content but it’s not invoking the onScroll event when I set the layout for my activity. If i comment that block then it invokes it just fine. How do I solve this issue?

package com.Threadtest;

import com.Threadtest.main.myRunnable;

import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AbsListView.OnScrollListener;

public class TestList extends ListActivity implements OnScrollListener {

    Aleph0 adapter = new Aleph0();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
        ListView listview=(ListView)findViewById(android.R.id.list);
        listview.setAdapter(adapter);
        /*setListAdapter(adapter); 
        getListView().setOnScrollListener(this);*/
    }

    public void onScroll(AbsListView view,
        int firstVisible, final int visibleCount, int totalCount) {

        Log.i("TestList", "firstVisible="+firstVisible+" visibleCount="+visibleCount+" totalCount="+totalCount);
        boolean loadMore = /* maybe add a padding */
            firstVisible + visibleCount >= totalCount;

        if(loadMore) {
            Log.i("TestList", "In Notify");
            Thread thread = new Thread()
            {
                  @Override
                  public void run() {
                      try {
                        this.sleep(10000);
                        runOnUiThread(new myRunnable(adapter,visibleCount));
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }


                  }
              };

            thread.start();

        }
    }

    public void onScrollStateChanged(AbsListView v, int s) { } 

    class myRunnable implements Runnable
    {
        Aleph0 adapter;

        public myRunnable(Aleph0 adapter,int visibleCount)
        {

            this.adapter=adapter;
            this.adapter.count += visibleCount;
        }
        public void run() {
            // TODO Auto-generated method stub
             Log.i("TestList", "List Count="+adapter.count);
                adapter.notifyDataSetChanged();
        }

    }

    class Aleph0 extends BaseAdapter {
        int count = 40; /* starting amount */

        public int getCount() { return count; }
        public Object getItem(int pos) { return pos; }
        public long getItemId(int pos) { return pos; }

        public View getView(int pos, View v, ViewGroup p) {
            if(pos!=count-1)
            {
                TextView view = new TextView(TestList.this);
                view.setText("entry " + pos);
                return view;
            }
            TextView view = new TextView(TestList.this);
            view.setText("Loading.. " + pos);
            return view;

        }
    }
}
  • 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-23T04:54:26+00:00Added an answer on May 23, 2026 at 4:54 am

    getListView().setOnScrollListener(this) is necessary to bind the listener to the ListView. The ListActivity class does not provide an “automatic” way of binding most of the listeners, It only provides an automatic way of binding the OnItemClickListener. Check out the ListActivity code.

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

Sidebar

Related Questions

No related questions found

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.