我尝试的方法:
1.直接调用,行不通。
2.强转,反射,也报错。
ProgressBar instance = (ProgressBar) this; @SuppressWarnings("unchecked") Class<ProgressBar> clazz = (Class<ProgressBar>) instance.getClass(); try { progressBarOnDraw = clazz.getDeclaredMethod("onDraw", Canvas.class); progressBarOnDraw.setAccessible(true); } catch (NoSuchMethodException e) { e.printStackTrace(); } if (progressBarOnDraw != null) { try { progressBarOnDraw.invoke((ProgressBar) this, canvas); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } } else { super.onDraw(canvas); }
<spanstyle="font-family:Consolas,'CourierNew',Courier,mono,serif;font-size:12px;line-height:18px;background-color:#F5FAE2;"> method.setAccessible(<spanstyle="color:blue;font-weight:bold;font-family:Consolas,'CourierNew',Courier,mono,serif;font-size:12px;line-height:18px;background-color:#F5FAE2;">true<spanstyle="font-family:Consolas,'CourierNew',Courier,mono,serif;font-size:12px;line-height:18px;background-color:#F5FAE2;">); 我设置了,还是不行呢。super.method();
集结各类场景实战经验,助你开发运维畅行无忧