findViewById(int) returns null on one specific button in Android 3.1 other versions its fine

StackOverflow https://stackoverflow.com/questions/8941118

문제

It's my first question but I'm trying to ask correctly.

As the title says only on one button and only in android 3.1 findViewById(int) returns null. Testing on Android 2.2 it works and all other buttons are found in both Android versions. It finds buttons before this specific line and afterwards.

public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonInfo = (Button)findViewById(R.id.buttonInfo);//fine
buttonInfo.setOnClickListener(this);
...
Button buttonCallOpScreen = (Button)findViewById(R.id.buttonCallOpScreen);//always returns null in android 3.1
...
Button buttonTakePicture = (Button)findViewById(R.id.buttonTakePictureMain);//fine
buttonTakePicture.setOnClickListener(this);
}

main.xml:

(I do know that I should not use px, but it shall work on my device only, so that's fine 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 a more than ugly. As there are several persons working on this project one of seemed to have changed the name in the layout-normal/main.xml. While Android-Versions before 3.1 seem to load layout/main.xml the newer ones use layout-normal/main.xml. And as it is more than understandable if the id of that button is a different findViewById(int) has to return null.

Sorry for bothering you with that and thanks for the comments!

As I do have less than 100 reputation, I can't answer my own question to close it, if anyone could post this answer I would accept it, thanks.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top