Check out example codes for "fragment button nullpointerexception". It will help you in understanding the concepts better.

Code Example 1

//You need to call findViewById in your root view instead:

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
    View layout = inflater.inflate(R.layout.activity_warrior_self_battle_recyclerview, container, false);
    recyclerView = (RecyclerView) layout.findViewById(;
    LinearLayoutManager layoutManager;

    //change to layout.findViewById():
    bStart = (Button) layout.findViewById(; //modified
    nP1 = (EditText) layout.findViewById(; //modified
    nP2 = (EditText) layout.findViewById(; //modified

    layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
    adapter = new WarriorBattleAdapter(getActivity());
    return layout;

Learn ReactJs, React Native from