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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:30:41+00:00 2026-06-02T20:30:41+00:00

The code which is used. I want the list to load once in the

  • 0

The code which is used. I want the list to load once in the beginning, and then load data on subsequent scrolls..

public class ViewPage extends ListActivity{

ListView lv;
ListAdapter ld;
int size=7;
String filename[] = new String[size];
Cursor contactcursor;
ArrayAdapter<String> arr_ad;
int contact_column_index;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    setContentView(R.layout.mylist);

    for(int i=0;i<size;i++)
        filename[i]=new String();


    String[] proj = { ContactsContract.Contacts.DISPLAY_NAME };
    contactcursor = managedQuery(ContactsContract.Contacts.CONTENT_URI, proj, null, null, null);
    contact_column_index = contactcursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME);
    lv = (ListView)findViewById(android.R.id.list);
    contactcursor.moveToFirst();
        for(int i=0;i<size;i++)
        {
            filename[i] = contactcursor.getString(contact_column_index);
            Toast.makeText(ViewPage.this, filename[i] +" ok "+ contactcursor.getString(contact_column_index) , 1).show();
            if(!contactcursor.moveToNext())
                break;
        }
        arr_ad = new ArrayAdapter<String>(ViewPage.this, android.R.layout.simple_list_item_1, filename);
        setListAdapter(arr_ad);
        lv.setOnScrollListener(new EndlessScrollListener());
}

public class EndlessScrollListener implements OnScrollListener {

private int visibleThreshold = size;
private int currentPage = 0;
private int previousTotal = 0;
private boolean loading = true;

public EndlessScrollListener() 
{

}

public EndlessScrollListener(int visibleThreshold) 
{
    this.visibleThreshold = visibleThreshold;
}

@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<size;i++)
            {
                filename[i] = contactcursor.getString(contact_column_index);
                Toast.makeText(ViewPage.this, filename[i] +" "+ contactcursor.getString(contact_column_index) , 1).show();
                arr_ad.add(filename[i]);
                if(!contactcursor.moveToNext())
                    break;

            }

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


            //setListAdapter(arr_ad);

            loading = true;
            Toast.makeText(ViewPage.this,totalItemCount+" "+visibleItemCount+" "+firstVisibleItem+" "+visibleThreshold+" ", 1).show();
     }
}

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    // TODO Auto-generated method stub

}

}
}

It shows error in line 98 which is arr_ad.add(filename[i]); and says that the operation is not supported. Could anyone help please! 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-02T20:30:42+00:00Added an answer on June 2, 2026 at 8:30 pm

    If you want to use add method of ArrayAdapter, you must give List<String> object (not String[]) in the constructor.

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

Sidebar

Related Questions

I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int
I have the following javascript code in place which is used to give hover
Does some PDO::PARAM_??? exist which can be used for dates or timestamps? Sample code:
The code I used doesn't give me any MySQL errors (which is good) Except
Is the C++ vtable only used for determining which section of code should be
I have a bunch of generic code that is used a lot, which i'd
Want to grab list of players from http://www.atpworldtour.com/Rankings/Singles.aspx There is a table with class
So I have a DataGridView which is used to display a list of custom
i created an iPad application, in which i used searchBar, in searchBar data is
Below is the piece of code which is used to get view for the

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.