当前位置 : 主页 > 手机开发 > android >

android – 如何正确扩展WebView?

来源:互联网 收集:自由互联 发布时间:2021-06-11
我正在使用 Scroll webview horizontally inside a ViewPager的解决方案 它看起来非常有用,我在xml中引用了ExtendedWebView, ExtendedWebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height=
我正在使用 Scroll webview horizontally inside a ViewPager的解决方案

它看起来非常有用,我在xml中引用了ExtendedWebView,

<ExtendedWebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>

.class中的实例ExtendedWebView,

LayoutInflater mInflater =  (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout  = mInflater.inflate(R.layout.lay1, null);
ExtendedWebView webView = (ExtendedWebView)layout.findViewById(R.id.webview);

但我得到’错误膨胀类ExtendedWebView’,所以任何人都可以帮助我给我一些想法,感谢您的时间和经验!

继承人是整个堆栈跟踪,

12-27 22:14:44.263: E/AndroidRuntime(10824): FATAL EXCEPTION: main
12-27 22:14:44.263: E/AndroidRuntime(10824): android.view.InflateException: Binary XML file line #7: Error inflating class com.vv_package_name.ExtendedWebView
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at com.vv_package_name.vv_main$ExtendedPagerAdapter.instantiateItem(vv_main.java:135)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:110)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:801)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.support.v4.view.ViewPager.populate(ViewPager.java:930)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1366)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.View.measure(View.java:8226)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.os.Looper.loop(Looper.java:123)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.app.ActivityThread.main(ActivityThread.java:4627)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at java.lang.reflect.Method.invokeNative(Native Method)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at java.lang.reflect.Method.invoke(Method.java:521)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at dalvik.system.NativeStart.main(Native Method)
12-27 22:14:44.263: E/AndroidRuntime(10824): Caused by: java.lang.ClassNotFoundException: com.vv_package_name.ExtendedWebView in loader dalvik.system.PathClassLoader[/data/app/com.vv_package_name-2.apk]
12-27 22:14:44.263: E/AndroidRuntime(10824):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.LayoutInflater.createView(LayoutInflater.java:466)
12-27 22:14:44.263: E/AndroidRuntime(10824):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
12-27 22:14:44.263: E/AndroidRuntime(10824):    ... 33 more

如果使用WebView而不是ExtendedWebView,我的代码工作正常:)

您需要提供该类的完整参考,包括包.

例如,

<org.example.myapp.ExtendedWebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
 />
网友评论