java.lang.NullPointerException on setOnClickListener in Fragment

前端 未结 1 460
执念已碎
执念已碎 2021-01-27 07:35

I\'m pretty new to Android and I\'m trying to create an application that will score matches of the Vex Robotics Competition. I have a ViewPager with fragments for e

相关标签:
1条回答
  • 2021-01-27 08:18

    Open your fragment_blue.xml layout. Your Button with id rAFloorGoalUp needs to be declared in this file.

    When it isn't

    Button rAFloorGoalUp = (Button) rootView.findViewById(R.id.rAFloorGoalUp);
    

    will be assigned null and

    rAFloorGoalUp.setOnClickListener(...)
    

    will raise a NullPointerException error.

    0 讨论(0)
提交回复
热议问题