My code is protected void onCreate(Bundle savedInstanceState)

 LayoutInflater factory = this.getLayoutInflater(); View main_buttons_layout_view = factory.inflate(R.layout.main_buttons_layout, null); View side_buttons_layout_view = factory.inflate(R.layout.side_buttons_layout, null); flipperUp = (Button) side_buttons_layout_view.findViewById(R.id.flipperUpButton); flipperDown = (Button) side_buttons_layout_view.findViewById(R.id.flipperDownButton); shortcut1Button = (Button) side_buttons_layout_view.findViewById(R.id.shortcutButton1); shortcut2Button = (Button) side_buttons_layout_view.findViewById(R.id.shortcutButton2); 

My markup in main_buttons_layout.xml

 <?xml version="1.0" encoding="utf-8"?> 

...

 <Button android:id="@+id/flipperDownButton" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="2dp" android:layout_marginRight="2dp" android:layout_weight="5" android:background="@drawable/flippernavigationbuttonstyle" android:text="down" android:textColor="#000000" /> ... 

Why is flipperDown always null ? Given that the rest of the buttons from the same layout are perfectly initialized.

  • Maybe it's not the markup - iFr0z
  • What then? - Yaktens Teed

1 answer 1

 flipperDown = (Button) side_buttons_layout_view.findViewById(R.id.flipperDownButton); 

change to

 flipperDown = (Button) main_buttons_layout_view.findViewById(R.id.flipperDownButton); 

You are looking for it in another layout

  • Overlooked XD Thank you - Yaktens Teed