Android Open Source - InfiniteScrollListView My Adapter






From Project

Back to project page InfiniteScrollListView.

License

The source code is released under:

MIT License

If you think the Android project InfiniteScrollListView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.sandersdenardi.infinitescrolllistview.app;
//from   w ww  .j  a  v a2s .  com
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sandersdenardi.infinitescrolllistview.app.lib.InfiniteScrollAdapter;

import java.util.ArrayList;
import java.util.Collection;

public class MyAdapter extends InfiniteScrollAdapter {

    private ArrayList<String> items;

    public MyAdapter(Context context) {
        super(context);
        items = new ArrayList<String>();
    }

    @Override
    public ArrayList getItems() {
        return items;
    }

    @Override
    public void addItems(Collection items) {
        if (items.size() > 0) {
            this.items.addAll(items);
        } else {
            super.setDoneLoading();
        }
        notifyDataSetChanged();
    }

    @Override
    public Object getRealItem(int position) {
        return items.get(position);
    }

    @Override
    public View getRealView(LayoutInflater inflater, int position, View convertView, ViewGroup parent) {
        View v = inflater.inflate(R.layout.list_item, null);
        ((TextView)v.findViewById(R.id.text_main)).setText(items.get(position));
        return v;
    }

    @Override
    public View getLoadingView(LayoutInflater inflater, ViewGroup parent) {
        return inflater.inflate(R.layout.list_loading, null);
    }
}




Java Source Code List

com.sandersdenardi.infinitescrolllistview.app.MainActivity.java
com.sandersdenardi.infinitescrolllistview.app.MyAdapter.java
com.sandersdenardi.infinitescrolllistview.app.lib.IInfiniteScrollListener.java
com.sandersdenardi.infinitescrolllistview.app.lib.InfiniteScrollAdapter.java
com.sandersdenardi.infinitescrolllistview.app.lib.InfiniteScrollListView.java
com.sandersdenardi.infinitescrolllistview.app.lib.InfiniteScrollOnScrollListener.java