This is my first question, but I'm trying to ask correctly.
As the title says with just one button and only in android 3.1 findViewById (int) returns null. Testing on Android 2.2 works, and all other buttons are in both versions of Android. He finds the buttons before this particular line and subsequently.
public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); Button buttonInfo = (Button)findViewById(R.id.buttonInfo);
main.xml :
(I know that I should not use px , but it should only work on my device, so this is normal for this case.)
<Button android:id="@+id/buttonInfo" android:text="" android:layout_width="332px" android:layout_height="100px" android:background="@drawable/btn_team" /> ... <Button android:id="@+id/buttonCallOpScreen" android:text="" android:layout_width="332px" android:layout_height="100px" android:background="@drawable/btn_operator" /> ... <Button android:id="@+id/buttonTakePictureMain" android:text="" android:layout_width="80px" android:layout_height="80px" android:background="@drawable/btn_take_picture" android:layout_gravity="bottom|left" />
Any help would be appreciated, thanks so far.
Answer:
It turned out to be more than ugly. Since several people are working in this project, it seems that this has changed the name in the normal / main.xml layout. Although Android versions prior to 3.1 seem to load layout / main.xml, new ones use layout-normal / main.xml. And since this is more than clear, if the identifier of this button is different from findViewById (int), it should return null.
Sorry to bother you about this and thanks for the comments!
Since I have less than 100 reputations, I cannot answer my question to close it, if anyone could post this answer, I would accept it, thanks.
source share