dynamic-load-apk
dynamic-load-apk copied to clipboard
解决this引用的问题
通过在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.
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(); }
有什么好的建议么?
这个问题解决了吗,求助啊