genius158 / InflaterAuto

a lib that make UI look the same in different android phones, 强大的屏幕适配库(AndroidAutoLayout替代方案),不只是适配!
81 stars 15 forks source link

在webView中使用有问题 #9

Open chenbo-boy opened 6 years ago

chenbo-boy commented 6 years ago

当和webView中的html5交互时,比如弹出输入框,由于 /**

genius158 commented 6 years ago

个人测试中并没有出现什么问题,还请提供机型android系统参数

chenbo-boy commented 6 years ago

h5页面中有标签时,会闪退. log: 07-10 16:57:07.127 18761-18761/xxx W/System.err: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class FrameLayout 07-10 16:57:07.128 18761-18761/xxx W/System.err: Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class FrameLayout 07-10 16:57:07.129 18761-18761/xxx W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.com.csii.jnbank.carloan.base.InfAutoFrameLayout" on path: DexPathList[[zip file "/data/app/xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/xxx-1/lib/arm, /data/app/xxx-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.android.webview.chromium.ResourcesContextWrapperFactory$WebViewContextWrapper$1.findClass(ResourcesContextWrapperFactory.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.view.LayoutInflater.createView(LayoutInflater.java:609) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:700) 07-10 16:57:07.130 18761-18761/xxx W/System.err: at com.yan.inflaterauto.AutoInflater.onCreateView(AutoInflater.java:126) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.inflate(LayoutInflater.java:495) at com.yan.inflaterauto.AutoInflater.inflate(AutoInflater.java:52) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at android.view.LayoutInflater.inflate(LayoutInflater.java:377) at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:1831) at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2666) at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2739) at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:419) 07-10 16:57:07.131 18761-18761/xxx W/System.err: at com.android.internal.app.AlertController.installContent(AlertController.java:245) at android.app.AlertDialog.onCreate(AlertDialog.java:433) at android.app.Dialog.dispatchOnCreate(Dialog.java:399) at android.app.Dialog.show(Dialog.java:299) at android.app.AlertDialog.show(AlertDialog.java:1246) at org.chromium.content.browser.input.SelectPopupDialog.show(SelectPopupDialog.java:162) at org.chromium.content.browser.ContentViewCore.showSelectPopup(ContentViewCore.java:2567) at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:39) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6406) 07-10 16:57:07.132 18761-18761/xxx W/System.err: at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)

chenbo-boy commented 6 years ago

h5中有select标签

chenbo-boy commented 6 years ago

怎么就去寻找“android.view.com.csii.jnbank.carloan.base.InfAutoFrameLayout”这个了,明明是“com.csii.jnbank.carloan.base.InfAutoFrameLayout”

chenbo-boy commented 6 years ago

刚才测试了下在华为平板FDR-A03L android系统5.1.1上面正常,但是在7.0以上的魅族,三星手机都闪退

genius158 commented 6 years ago

你可以尝试自己覆写 InfAutoInflaterConvert 实现类映射

public class InfAutoInflaterConvert extends InflaterConvert implements AutoConvert { public HashMap<String, String> getConvertMap() { //自己写的InflaterConvert可以先配置映射,这里会把先设置的映射添加进来 HashMap<String, String> classMap = new HashMap(); HashMap<String, String> superMap = super.getConvertMap(); if(superMap != null) { classMap.putAll(superMap); }

    classMap.put("android.support.v7.widget.RecyclerView", "com.yan.inflaterautotest.InfAutoRecyclerView");
    classMap.put("android.support.design.widget.CoordinatorLayout", "com.yan.inflaterautotest.InfAutoCoordinatorLayout");
    classMap.put("com.yan.inflaterautotest.AutoLayout", "com.yan.inflaterautotest.InfAutoAutoLayout");
    classMap.put("ListView", "com.yan.inflaterautotest.InfAutoListView");
    classMap.put("ScrollView", "com.yan.inflaterautotest.InfAutoScrollView");
    classMap.put("FrameLayout", "com.yan.inflaterautotest.InfAutoFrameLayout");
    classMap.put("android.support.v4.widget.NestedScrollView", "com.yan.inflaterautotest.InfAutoNestedScrollView");
    classMap.put("android.support.constraint.ConstraintLayout", "com.yan.inflaterautotest.InfAutoConstraintLayout");
    classMap.put("LinearLayout", "com.yan.inflaterautotest.InfAutoLinearLayout");
    return classMap;
}

}