有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java加载消息未隐藏在Recyclerview 安卓中

我正在使用endless ^{},它正在从Parse.com数据库加载数据。我面临的问题是,它显示了两个加载图像,如下图所示。我想一次显示一个项目,然后滚动显示图标,然后加载下一个项目

Endlesscroll的代码为-

public abstract class EndlessScroll extends RecyclerView.OnScrollListener {
    public static String TAG = EndlessScroll.class.getSimpleName();

    private int previousTotal = 0; // The total number of items in the dataset after the last load
    private boolean loading = true; // True if we are still waiting for the last set of data to load.
    private int visibleThreshold = 2; // The minimum amount of items to have below your current scroll position before loading more.
    int firstVisibleItem, visibleItemCount, totalItemCount;

    Context context;    
    private int current_page = 1;    
    private LinearLayoutManager mLinearLayoutManager;

    public EndlessScroll(LinearLayoutManager linearLayoutManager, Context context) {
        this.mLinearLayoutManager = linearLayoutManager;
        this.context = context;
    }

    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        super.onScrolled(recyclerView, dx, dy);  

        visibleItemCount = recyclerView.getChildCount();
        totalItemCount = mLinearLayoutManager.getItemCount();
        firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();

        if (loading) {     
            if (totalItemCount > previousTotal) {
                loading = false;
                previousTotal = totalItemCount;
            }
        }
        if (!loading && (totalItemCount - visibleItemCount)
                <= (firstVisibleItem + visibleThreshold)) {    

            // End has been reached    
            // Do something
            current_page++;
            onLoadMore(current_page);    
            loading = true;
        }
    }    
    public abstract void onLoadMore(int current_page);
}

enter image description here

我最近开始在安卓系统工作

我不知道为什么装载行为有问题

非常感谢你的帮助/建议/任何指点


共 (0) 个答案