NullPointerException when using ListView inside a ViewStub
问题 I'm trying to create a ListView inside a ViewStub, but i keep on getting a NullPointerException . My Buttons works as intended inside the ViewStub. The code that fails is as following: else if(v.getId() == R.id.comments_button_series_view){ if(stubUsed == false){ stub = (ViewStub) findViewById(R.id.stub); View inflatedStub = stub.inflate(); String[] comments = new String[]{"comment1", "comment2"}; commentsAdapter = new ArrayAdapter<String>(this, R.layout.patient_list_element, R.id.comments