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

  • Home
  • SEARCH
  • 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 7843259
In Process

The Archive Base Latest Questions

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

I have a listview utilizing a custom adapter, now I want it to show

  • 0

I have a listview utilizing a custom adapter, now I want it to show the first five entries and load the others when I scroll down, what’s the simplest way to do this?

If my code for the list is

public class Second extends Activity  {

static final String Li_nk="LinkName:";
static final String Image_name="ImageName:";
//ListView list;
public final static String AUTH = "authentication";
static final String KEY_THUMB_URL = "thumb_image";      //Uri.decode("http://zeesms.info/android_app_images/Koala.jpg");
//JSONObject j2;
String wrd;
//ArrayList<HashMap<String,String>> mylist;
@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent i2=getIntent();
     wrd=i2.getStringExtra("entrd");
    Log.v("keyis",wrd);



    final Handler handler = new Handler();
    Runnable runable = new Runnable() {

        @Override
        public void run() {

            //call the function
            LoadData();
            //also call the same runnable
            handler.postDelayed(this, 40000);
        }
    };
    handler.postDelayed(runable, 10);

}public void LoadData(){


     JSONObject j2=JSONfunctions.getJSONfromURL("/webservice_search.php?keyword="+wrd+"&format=json");
     ArrayList<HashMap<String,String>> mylist = new  ArrayList<HashMap<String,String>>();

     try{JSONArray jray=j2.getJSONArray("listings");
        for(int i=0;i<jray.length();i++){
            Log.v("state","json data being read");
            JSONObject j3= jray.getJSONObject(i);
            String first=j3.getString("listing");
            Log.v("sublist", first);
            JSONObject j4=j3.getJSONObject("listing");
            String sec=j4.getString("links");

            int maxLength = (sec.length() < 30)?sec.length():27;
            sec.substring(0, maxLength);
            String cutsec=sec.substring(0,maxLength);
            Log.v("links are",cutsec);
            String img=j4.getString("image_name");
            Log.v("image name is ",img);
            //Uri dimg=Uri.parse("http://zeesms.info/android_app_images/Koala.jpg");
            HashMap<String,String> map=new HashMap<String,String>();

            map.put("Id",String.valueOf(i));
            map.put(Li_nk,cutsec);
            map.put(Image_name,j4.getString("image_name"));

            map.put(KEY_THUMB_URL,"http://zeesms.info/android_app_images/"+img);

             mylist.add(map);

        }

        }
        catch(JSONException e){

            Log.e("loG_tag","Error parsing"+e.toString());
        }
     LazyAdapter adapter = new LazyAdapter(this,mylist);
     adapter.notifyDataSetChanged();
    // list.setSelection(positionToMove);

        ListView list=(ListView)findViewById(R.id.lv1);
         list.setEmptyView(findViewById(R.id.empty));
         list.setAdapter(adapter);

        // list.setStackFromBottom(true);
            list.setItemsCanFocus(false);
           // list.smoothScrollToPosition(3,5);
            list.setOnItemClickListener(new AdapterView.OnItemClickListener(){

                @Override
                public void onItemClick(AdapterView<?> parent, View view,
                        int position, long id) {
                    //Toast.makeText(getApplicationContext(),"Click ListItem Number " + position, Toast.LENGTH_LONG).show();
                    Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.riffre.com/"));
                    startActivity(myIntent);
                }

            });
           list.setOnScrollListener(new OnScrollListener(){

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem,
                    int visibleItemCount, int totalItemCount) {
                // TODO Auto-generated method stub

            }

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

            }

           });
}

and the code for the adapter class extending baseadapter is

public class LazyAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader; 


public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
    activity = a;
    data=d;
    Collections.reverse(d);
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return data.size();
}

@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}



@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)

        vi = inflater.inflate(R.layout.custom_row_view1, null);

    TextView title = (TextView)vi.findViewById(R.id.linkname); // merchnts name
    TextView artist = (TextView)vi.findViewById(R.id.imagename); // address
    //TextView duration = (TextView)vi.findViewById(R.id); // distance
   ImageView thumb_image=(ImageView)vi.findViewById(R.id.mClogo); // logo

    HashMap<String, String> jsn = new HashMap<String, String>();
    jsn = data.get(position);

    // Setting all values in listview
   title.setText(jsn.get(Second.Li_nk));
   artist.setText(jsn.get(Second.Image_name));
    //duration.setText(song.get(CustomizedListView.KEY_DURATION));
    imageLoader.DisplayImage(jsn.get(Second.KEY_THUMB_URL), thumb_image);
    return vi;
}

}

and I have a different class for parsing the json data in the list. So what would be the simplest way to implement endless scrolling?

Any help would be greatly appreciated…

  • 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-02T16:30:39+00:00Added an answer on June 2, 2026 at 4:30 pm

    Found the solution by declaring my list as a global variable. Thanks anyway for your help.

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

Sidebar

Related Questions

I have a listview extends Activity and use custom adapter because I want icon
First of all I have a simple ListView . Implementing the BaseAdapter and utilizing
I have ListView with custom Adapter which supplies View to ListView in this way:
I have a ListView with a Custom Adapter, and I need to access the
I have a ListView with a GridView with 3 columns. I want last column
I have a listview that has multiple entries and each entry has 2 subitems.
I have listView in which I inflate a row contain textview and button now
I have a ListView that contains 3 checkboxes per row. I want to set
I have a ListView with each item being a custom layout with multiple Views
i have a listView with a custom BaseAdapter.Every list item has a clickable button.

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.