Okay, I'm new to both java and android programming, but I've come across the most frustrating error ever and I can't seem to be able to find the solution. here is where the error is at.
final Button button = (Button) findViewById(R.id.activity_button);
And here is the XML of the button itself.
<Button
android:id="@+id/button_main"
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/button_text" />
I'm not seeing the problem, I imported import com.awesometech.uselessbutton.R; which didn't help. Any suggestions? I'm using Eclipse.
Change to
final Button button = (Button) findViewById(R.id.button_main);
You have
<Button
android:id="@+id/button_main" // id is button_main not activity_button
Probably activity_button id belongs to another view and you are casting it to a Button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With