如何将更多项目加载到listview中滚动到底部

时间:2016-10-18 01:22:13

标签: android listview arraylist

我将大约25个项目加载到ArrayList中,并根据需要设置适配器。我想知道,有没有办法加载数组列表4中的每个项目(或一次5个)。我将如何为常规列表视图执行此操作?我不想做的是从数据库加载更多我只想对查询得到的内容进行更多操作。我尝试this作为参考,但我并不完全认为这会适用,因为我需要一个列表视图,而不是回收者视图。

以下是我认为我应该做的一些示例代码:

public class StartEsole extends FragmentActivity implements OnMapReadyCallback, LocationListener {

    ListView listview;
    ArrayList<Details> businessList = new ArrayList<>();
    aggregateTaskBars taskBars;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        listview = (ListView) findViewById(R.id.whatsLit);
        mySwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
        mySwipeRefreshLayout.setRefreshing(true);

        taskBars = new aggregateTaskBars();
        taskBars.execute();

        //How would I set it to only 5 items and scroll to bottom and load 5 more
        listview.scrollToBottom( add 5 more items from businesslist and populate them into listview)

        mySwipeRefreshLayout.setOnRefreshListener(
                    new SwipeRefreshLayout.OnRefreshListener() {
                    @Override
                    public void onRefresh() {
                        Log.i("AppInfo", "onRefresh called from SwipeRefreshLayout");
                        lookForWhatsLit();
                    }
                }

        );
    }

    public class aggregateTaskBars extends AsyncTask<String, Void, String> {

        @Override
        protected String doInBackground(String... params) {
            //Populate items into Arraylist businessList that contains details of some kind
            //should produce 20
            return null

        }
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
            mySwipeRefreshLayout.setRefreshing(false);
            listview.setAdapter(vDetailAdapter);
            vDetailAdapter.notifyDataSetChanged();
            valueType.setEnabled(true);
        }



}

0 个答案:

没有答案