When I Use The Back Button In Activity My App Crashes After I Click A Button In The App
package com.example.submenus; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.widget.Button; public class MainActivity extends Act
Solution 1:
If you are setting two different views on a button click, why don't you create two different activities and set content those views in those activities.
Then you can call those activities from those button click listeners. It is fast efficient and your app will not crash.
java.lang.IllegalStateException: Could not find a method ButtonOnClick(View) in the activity classcom.example.submenus.MainActivity for onClick handler on view classandroid.widget.Button withid'a4button'
This errors means that you do not have a method named ButtonOnClick(View)
for button with id a4button
.
Remove those final modifiers also
Solution 2:
Your problems are from calling setContentView() multiple times. Use a ViewFlipper with setDisplayedChild() or a FrameLayout with multiple views, or start a new Activity for each button click. See Calling setContentView() multiple times
Post a Comment for "When I Use The Back Button In Activity My App Crashes After I Click A Button In The App"