Home > Mobile >  I am going to be crazy about recycleview null pointer errors please great god answer! Genuflect is b
I am going to be crazy about recycleview null pointer errors please great god answer! Genuflect is b

Time:10-03

Error description:
E/AndroidRuntime: FATAL EXCEPTION: the main
Process: com. Sxau. Qy justright, PID: 5943
Java. Lang. RuntimeException: Unable to start the activity ComponentInfo {com. Sxau. Qy. Justright/com. Sxau. Qy. Justright, MainActivity} : 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
. An android app. ActivityThread. PerformLaunchActivity (ActivityThread. Java: 2913)
. An android app. ActivityThread. HandleLaunchActivity (ActivityThread. Java: 3048)
An android. App. Servertransaction. LaunchActivityItem. Execute (LaunchActivityItem. Java: 78)
An android. App. Servertransaction. TransactionExecutor. ExecuteCallbacks (TransactionExecutor. Java: 108)
An android. App. Servertransaction. TransactionExecutor. Execute (TransactionExecutor. Java: 68)
An android. App. ActivityThread $H.h andleMessage (ActivityThread. Java: 1808)
An android. OS. Handler. DispatchMessage (Handler. Java: 106)
. An android OS. Stars. Loop (193). Which Java:
. An android app. ActivityThread. Main (6669) ActivityThread. Java:
The at Java. Lang. Reflect. Method. Invoke (Native Method)
At com. Android. Internal. OS. RuntimeInit $MethodAndArgsCaller. Run (493) RuntimeInit. Java:
At com. Android. Internal. OS. ZygoteInit. Main (ZygoteInit. Java: 858)
Under Caused by: 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
At com. Sxau. Qy. Justright. MainActivity. OnCreate (MainActivity. Java: 67)
. An android app. Activity. PerformCreate (7136) Activity. Java:
. An android app. Activity. PerformCreate (7127) Activity. Java:
. An android app. Instrumentation. CallActivityOnCreate (1271) Instrumentation. Java:
. An android app. ActivityThread. PerformLaunchActivity (ActivityThread. Java: 2893)
. An android app. ActivityThread. HandleLaunchActivity (ActivityThread. Java: 3048)
An android. App. Servertransaction. LaunchActivityItem. Execute (LaunchActivityItem. Java: 78)
An android. App. Servertransaction. TransactionExecutor. ExecuteCallbacks (TransactionExecutor. Java: 108)
An android. App. Servertransaction. TransactionExecutor. Execute (TransactionExecutor. Java: 68)
An android. App. ActivityThread $H.h andleMessage (ActivityThread. Java: 1808)
An android. OS. Handler. DispatchMessage (Handler. Java: 106)
. An android OS. Stars. Loop (193). Which Java:
. An android app. ActivityThread. Main (6669) ActivityThread. Java:
The at Java. Lang. Reflect. Method. Invoke (Native Method)
At com. Android. Internal. OS. RuntimeInit $MethodAndArgsCaller. Run (493) RuntimeInit. Java:
At com. Android. Internal. OS. ZygoteInit. Main (ZygoteInit. Java: 858)
I/Process: Sending signal. PID: 5943 SIG: 9
The Application terminated.

CodePudding user response:

Public class MainActivity extends BaseActivity implements the View. An OnClickListener {

//will each text and ICONS in the linear layout controls generated (listen) to achieve click,
Private LinearLayout TextAndIcon_ID_justright;
Private LinearLayout TextAndIcon_ID_findout;
Private LinearLayout TextAndIcon_ID_news;
Private LinearLayout TextAndIcon_ID_fresh;
Private LinearLayout TextAndIcon_ID_self;

//will each icon button to generate (in order to change the icon),
Private ImageButton IconChange_ID_justright;
Private ImageButton IconChange_ID_findout;
Private ImageButton IconChange_ID_news;
Private ImageButton IconChange_ID_fresh;
Private ImageButton IconChange_ID_self;

//will each fragment instantiate layout,
//will each debris generated layout,
Private fragments justright_fragment;
Private fragments findout_fragment;
Private fragments news_fragment;
Private fragments fresh_fragment;
Private fragments self_fragment;

Private List (a);//new
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);//remove the top of the head bar
setContentView(R.layout.activity_main);//loading layout file
//initView ();//before all entities without initialization, the function is to initialize all
//selectTab (0);//the layout of the choice should be displayed to replace, through the refs decided to
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! The new
initCards ();
RecyclerView RecyclerView=the findViewById (R.i d.L istView);
//LinearLayoutManager layoutManager=new LinearLayoutManager (this);
LinearLayoutManager layoutManager=new LinearLayoutManager (this);
RecyclerView. SetLayoutManager (layoutManager);
//layoutManager. SetOrientation (OrientationHelper. VERTICAL);
CardsAdapter adapter=new CardsAdapter (cardsList);
RecyclerView. SetAdapter (adapter);


InitView ();//before all entities without initialization, the function is to initialize all
SelectTab (0);//the layout of the choice should be displayed to replace, through the refs decided to
}
//new
Private void initCards () {
for (int i=0; I<2; I++) {
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related