dynamic-load-apk icon indicating copy to clipboard operation
dynamic-load-apk copied to clipboard

解决this引用的问题

Open kevlia opened this issue 9 years ago • 2 comments

通过在DLBasePluginActivity的attach方法里面增加 attachBaseContext(mProxyActivity.getBaseContext()); 可以解决this变量引起的大部分空指针问题。 但是后面碰到一个问题,调用LayoutInflater去inflate一个layout的时候,对于layout里面的控件的属性,无法读出资源引用,报错: 08-05 12:03:52.610: E/java.lang.Thread(10286): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0202d2 a=-1 r=0x7f0202d2} 08-05 12:03:52.610: E/java.lang.Thread(10286): at android.content.res.Resources.loadDrawable(Resources.java:2192) 08-05 12:03:52.610: E/java.lang.Thread(10286): at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 08-05 12:03:52.610: E/java.lang.Thread(10286): at android.view.View.(View.java:3555) 08-05 12:03:52.610: E/java.lang.Thread(10286): at android.widget.ImageView.(ImageView.java:140) 08-05 12:03:52.610: E/java.lang.Thread(10286): at android.widget.ImageView.(ImageView.java:136)

layout的加载方式如下: LayoutInflater inflater = (LayoutInflater) mPluginActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); XmlResourceParser parser =mPluginActivity.getResources().getLayout(resId); try { content = newInflater.inflate(parser, null, false); } finally { parser.close(); }

有什么好的建议么?

kevlia avatar Aug 05 '15 11:08 kevlia

这个问题解决了吗,求助啊

jiangfei891111 avatar Aug 15 '16 08:08 jiangfei891111