Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use instantiateItem correctly with a mixture of view and layouts objects?
    primarykey
    data
    text
    <p>I'm trying to get this code to work:</p> <pre><code> @Override public Object instantiateItem(ViewGroup collection, int position) { View v = null; if( 0 == position ) { String data = "&lt;html&gt;&lt;body&gt;Hi there&lt;/body&gt;&lt;html&gt;"; WebView wv = (WebView) findViewById(R.id.webView); wv.loadData(data, "text/html", null); v = wv; } else { LayoutInflater vi = (LayoutInflater) cxt.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.editor, null); } collection.addView(v,0); return v; } </code></pre> <p>I'm basically mimicking this article here to build a horizontally swiping view: <a href="http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html" rel="nofollow">http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html</a></p> <p>I get a crash when I use this code. I gather I am not doing things correctly by trying to insert a layout into the ViewGroup. Any suggestions? </p> <pre><code>03-20 14:49:55.037: ERROR/AndroidRuntime(25990): FATAL EXCEPTION: main java.lang.NullPointerException at com.EditorHyde.app.b.a(Unknown Source) at android.support.v4.view.ViewPager.a(Unknown Source) at android.support.v4.view.ViewPager.a(Unknown Source) at android.support.v4.view.ViewPager.c(Unknown Source) at android.support.v4.view.ViewPager.onMeasure(Unknown Source) at android.view.View.measure(View.java:15518) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:15518) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:15518) at android.widget.LinearLayout.measureVertical(LinearLayout.java:847) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:15518) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176) at android.view.View.measure(View.java:15518) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749) at android.view.Choreographer.doCallbacks(Choreographer.java:562) at android.view.Choreographer.doFrame(Choreographer.java:532) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5041) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload