У меня есть это, казалось бы, невинное findViewById()
в моем onCreate()
, которое постоянно возвращает ноль:
mCheckLicenseButton = (Button) findViewById(R.id.btn_checkout);
Мой res/layout/main.xml
явно содержит эту кнопку:
<Button android:id="@+id/btn_checkout"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/top_textview"
android:layout_alignParentRight="true"
android:text="Check License" />
Так что яне понимаю, почему findViewById()
возвращает ноль.
При каких обстоятельствах findViewById()
возвращает ноль?
Очевидно, что findViewById()
не удается найти ресурс макета, но что может объяснить это?