Android将适配器连接到RecyclerView

时间:2016-02-26 22:14:47

标签: android

阅读了很多帖子,比如这个错误,我无法解决这个问题。运行android应用程序后,我收到此错误:

E/RecyclerView: No adapter attached; skipping layout

我的代码:

private LatestNewsAdapter adapter;

@Override
public void parse_latest_news(String result, int code) {
    set_reload_status(false);
    if (code != 100) {
        Utils.handle_error_codes(base_activity, code);
    } else {
        ArrayList<LatestNewsModel> data = LatestNewsXMLParser.parse_user_xml_data(result);
        LinearLayoutManager llm = new LinearLayoutManager(base_activity);
        llm.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(llm);

        adapter = new LatestNewsAdapter(data, base_activity);
        recyclerView.setAdapter(adapter);

        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }
}

0 个答案:

没有答案