+ 3
Switch in AlertDialog Android
I started learning Android programming and making small demo apps like custom adapters, alertDialogs, etc. But recently I got a problem with them. I was trying immersive mode and worked without problem, and simple switch widget, which was perfectly working too. But when I combined them both to show a dialog with three switches for: 1: Full screen 2: Navigation bar 3: Immersive mode (sticky) but if I implement onclick listener, it does nothing, and if I add onclick in XML it crashes.What can be the problem?
4 Answers
+ 9
A condump from logcat containing the exception which is thrown may help to better identify the cause of the problem.
+ 3
AndroidRuntime FATAL EXCEPTION: main
12-23 09:55:23.004 7495 7495 E AndroidRuntime Process: com.mycompany.myapp2, PID: 7495
12-23 09:55:23.004 7495 7495 E AndroidRuntime java.lang.IllegalStateException: Could not find a method to(View) in the activity class android.view.ContextThemeWrapper for onClick handler on view class android.widget.ToggleButton with id 'statBarHide'
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.view.View$1.onClick(View.java:4061)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.view.View.performClick(View.java:4848)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.widget.CompoundButton.performClick(CompoundButton.java:120)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.view.View$PerformClick.run(View.java:20262)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.os.Handler.handleCallback(Handler.java:815)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:104)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.os.Looper.loop(Looper.java:194)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:5637)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at java.lang.reflect.Method.invoke(Native Method)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at java.lang.reflect.Method.invoke(Method.java:372)
+ 3
12-23 09:55:23.004 7495 7495 E AndroidRuntime at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
12-23 09:55:23.004 7495 7495 E AndroidRuntime Caused by: java.lang.NoSuchMethodException: to [class android.view.View]
12-23 09:55:23.004 7495 7495 E AndroidRuntime at java.lang.Class.getMethod(Class.java:664)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at java.lang.Class.getMethod(Class.java:643)
12-23 09:55:23.004 7495 7495 E AndroidRuntime at android.view.View$1.onClick(View.java:4054)
12-23 09:55:23.004 7495 7495 E AndroidRuntime ... 11 more
+ 3
anyone???