Using CardView and RecyclerView in my layout files throws an exception

前端 未结 4 1262
[愿得一人]
[愿得一人] 2021-02-13 20:06

So I\'ve been taking a shot at the Material Design of Android Preview L. I imported both the CardView and the RecyclerView libraries.

I use the

4条回答
  •  有刺的猬
    2021-02-13 20:53

    I found Similar Issue. As such if we only inflate layout which consist RecyclerView then While doing setcontentView it gives error because layout manager is not set for Recyclerview Defined in Layout file.

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.searchResultsList);
    LinearLayoutManager layoutmanager = new LinearLayoutManager(this);
    layoutmanager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(layoutmanager);
    

提交回复
热议问题