Error information:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.myapplication1, PID: 4782 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication1/com.example.myapplication1.Activity_main}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$**LayoutManager)' on a null object reference
My code in MainActivity:
RecyclerView recyclerView = findViewById(R.id.recycler_view);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
My app shows "AppName has stopped" "keep stopping", when it runs.I guess the parameter "this" maybe wrong ,because when I don't use fragment and put the RecyclerView in the MainActivity.xml rather than in the fragment.xml ,there is nothing wrong.But the context is too hard for me now ,and it's useless to use the parameter like "getApplicationContext()".