Какие могут быть причины, по которым кнопка имеет значение NULL?
Button press;
//...
press = (Button) findViewById (R.id.enter);
if (press != null)
press.setOnClickListener(this);
Я проверил манифест, XML-файл, код ... У меня нет дубликатов R.id.enterвсе еще кнопка NULL ... Все это произошло после того, как я ввел новую активность ...
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
press = (Button) findViewById (R.id.enter);
if (press != null)
press.setOnClickListener(this);
}
XML здесь (main.xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gift2"
>
<Button
android:id="@+id/enter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="415dp"
android:background="@drawable/pattern"
android:layout_gravity="center_horizontal"
android:text="Open your box now!"
android:textSize="20sp"
/>
</LinearLayout>