如何滚动到listview的bot

时间:2016-05-09 11:28:51

标签: java android android-layout listview

我的List View充满了来自服务器的数据,当用户轻扫僵尸时,它会添加另外8个项目列表,但问题是每次用户滚动时滚动到顶部。如何设置滚动到列表中的最后一项。我试过了 listview.smoothScrollToPosition(merchantadapter.getcount()); 但它不起作用

这是我的刷新方法

的实现
  swipyRefreshLayout = (SwipyRefreshLayout) rootView.findViewById(R.id.refreshsales);
    swipyRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh(SwipyRefreshLayoutDirection direction) {
            if (direction == SwipyRefreshLayoutDirection.BOTTOM) {
                index++;

                swipyRefreshLayout.setRefreshing(false);
                showlist();



            progressBar.dismiss();


            }
        }
    });

    showlist();
    return rootView;
}

2 个答案:

答案 0 :(得分:0)

轻松将其添加到列表视图的XML中:

android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"

答案 1 :(得分:0)

我设法为我的问题创建解决方案我会在这里发布给其他可能需要它的人:

 int firstitemposition=0;
 int currentposition= list.getFirstVisiblePosition();
 list.setSelectionFromTop(currentposition,firstitemposition);