Cause for NullPointerException android.support.v7.widget.RecyclerView.onMeasure

后端 未结 4 1178
北海茫月
北海茫月 2020-12-15 17:44

I am getting following Exception

01-27 11:15:15.756  18348-18348/com.example.pnimje.newswipelistview E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.Nu         


        
4条回答
  •  有刺的猬
    2020-12-15 17:58

    Antón response is good but can be confusing in beginners like me, talves this serves to clarify some doubts.

    RecyclerView rv;
    
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_buscar);
    
        rv = (RecyclerView) findViewById(R.id.RecViewTest);
        LinearLayoutManager llm = new LinearLayoutManager(this);
        rv.setLayoutManager(llm);
    
    
    }
    

提交回复
热议问题