小编Bun*_*nny的帖子

Android - 防止在notifyDataSetChanged()上滚动到底部

我正在构建一个聊天应用程序,我需要向上滚动以加载更多数据.但是当我把notifyDataSetChanged()我的ListView卷轴调到底部时.

我的ListView:

    <ListView
        android:id="@+id/list_messages"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:transcriptMode="alwaysScroll"
        android:stackFromBottom="true">
    </ListView>
Run Code Online (Sandbox Code Playgroud)

BaseAdapter是这样的:

public class CompleteListAdapter extends BaseAdapter {  
      private Activity mContext;  
      private List<String> mList;  
      private LayoutInflater mLayoutInflater = null;  
      public CompleteListAdapter(Activity context, List<String> list) {  
           mContext = context;  
           mList = list;  
           mLayoutInflater = (LayoutInflater) mContext  
                     .getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
      }  
      @Override  
      public int getCount() {  
           return mList.size();  
      }  
      @Override  
      public Object getItem(int pos) {  
           return mList.get(pos);  
      }  
      @Override  
      public long getItemId(int position) {  
           return position; …
Run Code Online (Sandbox Code Playgroud)

android

4
推荐指数
1
解决办法
2896
查看次数

标签 统计

android ×1