Open jmvines opened 9 years ago
+1 Surprised this hasn't been fixed, the checkbox is a little sketchy anyway, method names are slightly different for example (isCheck() or setOncheckListener()). For the moment we're probably better off sticking with the stock check box
Caused by: java.lang.NullPointerException at com.gc.materialdesign.views.CheckBox.invalidate(CheckBox.java:83)
just code check if it != null at CheckBox.java:83
/**
Created by lfd on 2015/10/28. */ public class FixCheckBox extends CheckBox{
public FixCheckBox(Context context, AttributeSet attrs) { super(context, attrs); }
@Override public void invalidate() { try { Object obj = null; Field field = CheckBox.class.getDeclaredField("checkView"); if(field!=null){ field.setAccessible(true); obj = field.get(this); } if(obj != null){ super.invalidate(); } } catch (Exception e) { e.printStackTrace(); } }
try it
Hi guys,
CheckBox works in API > 10, but in API 10 generates this crash.
android.view.InflateException: Binary XML file line #58: Error inflating class com.gc.materialdesign.views.CheckBox at android.view.LayoutInflater.createView(LayoutInflater.java:518) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570) at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) at android.view.LayoutInflater.inflate(LayoutInflater.java:408) at android.view.LayoutInflater.inflate(LayoutInflater.java:320) at android.view.LayoutInflater.inflate(LayoutInflater.java:276) at com.afollestad.materialdialogs.MaterialDialog$Builder.customView(MaterialDialog.java:1313) at com.resem.app.fragments.DetailDevelopmentAdvertFragment$2.onClick(DetailDevelopmentAdvertFragment.java:200) at android.view.View.performClick(View.java:2485) at android.view.View$PerformClick.run(View.java:9080) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:415) at android.view.LayoutInflater.createView(LayoutInflater.java:505) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570) at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) at android.view.LayoutInflater.rInflate(LayoutInflater.java:626) at android.view.LayoutInflater.inflate(LayoutInflater.java:408) at android.view.LayoutInflater.inflate(LayoutInflater.java:320) at android.view.LayoutInflater.inflate(LayoutInflater.java:276) at com.afollestad.materialdialogs.MaterialDialog$Builder.customView(MaterialDialog.java:1313) at com.resem.app.fragments.DetailDevelopmentAdvertFragment$2.onClick(DetailDevelopmentAdvertFragment.java:200) at android.view.View.performClick(View.java:2485) at android.view.View$PerformClick.run(View.java:9080) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.gc.materialdesign.views.CheckBox.invalidate(CheckBox.java:83) at android.view.View.setBackgroundDrawable(View.java:7626) at android.view.View.(View.java:2160)
at android.view.View.(View.java:1899)
at android.view.ViewGroup.(ViewGroup.java:286)
at android.widget.RelativeLayout.(RelativeLayout.java:173)
at com.gc.materialdesign.views.CustomView.(CustomView.java:22)
at com.gc.materialdesign.views.CheckBox.(CheckBox.java:32)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.view.LayoutInflater.createView(LayoutInflater.java:505)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.afollestad.materialdialogs.MaterialDialog$Builder.customView(MaterialDialog.java:1313)
at com.resem.app.fragments.DetailDevelopmentAdvertFragment$2.onClick(DetailDevelopmentAdvertFragment.java:200)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Thanks.