有两个活动我收到此错误:
这两项活动都在使用FragmentPagerAdapter
。
First Fragment ::
在第一个Fragment
中,我动态地inflating
布局并在UI中显示它。它在水平视图中工作正常,但当我将设备的orientation
更改为portrait
时,它给出了如下错误::
10-13 11:03:34.580: E/AndroidRuntime(9112): java.lang.StackOverflowError
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.text.BoringLayout.draw(BoringLayout.java:400)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.widget.TextView.onDraw(TextView.java:5265)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11177)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.buildDrawingCache(View.java:10894)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2755)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10614)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11282)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.widget.FrameLayout.draw(FrameLayout.java:450)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.widget.ScrollView.draw(ScrollView.java:1788)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10614)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10614)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10614)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.support.v4.view.ViewPager.draw(ViewPager.java:1923)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10614)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.widget.FrameLayout.draw(FrameLayout.java:450)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10616)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10614)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.getDisplayList(View.java:10614)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.view.View.draw(View.java:11180)
10-13 11:03:34.580: E/AndroidRuntime(9112): at android.v
第一个片段膨胀片段::
if ( !Utils.isTablet( getActivity() ) || is7inchTablet()
|| getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT )
{
layoutMultipleChoiceButtons = inflater.inflate( R.layout.layout_multiple_choice_buttons_hdpi_tablet, null );
layoutTrueFalseButtons = inflater.inflate( R.layout.layout_true_false_buttons_hdpi_tablet, null );
layoutFillInTheBlanks = inflater.inflate( R.layout.layout_fill_in_the_blanks_hdpi_tablet, null );
}
else
{
layoutMultipleChoiceButtons = inflater.inflate( R.layout.layout_multiple_choice_buttons, null );
layoutTrueFalseButtons = inflater.inflate( R.layout.layout_true_false_buttons, null );
layoutFillInTheBlanks = inflater.inflate( R.layout.layout_fill_in_the_blanks, null );
// vw = inflater.inflate( R.layout.layout_question_view, null );
}
我尝试删除inflated
视图,然后它在两个方向都正常工作。在充气视图期间出现任何问题。
第二个片段::
与发生在第二个fragment
的第一个fragment
相同。在这里,我还动态地在fragment
中动态展示视图,这使得方向更改错误为vertical
。
10-13 10:42:56.910: E/AndroidRuntime(8089): java.lang.StackOverflowError
10-13 10:42:56.910: E/AndroidRuntime(8089): at java.lang.ref.FinalizerReference.<init>(FinalizerReference.java:34)
10-13 10:42:56.910: E/AndroidRuntime(8089): at java.lang.ref.FinalizerReference.add(FinalizerReference.java:48)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.graphics.Canvas$CanvasFinalizer.<init>(Canvas.java:94)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.graphics.Canvas.<init>(Canvas.java:119)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.HardwareCanvas.<init>(HardwareCanvas.java:29)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.GLES20Canvas.<init>(GLES20Canvas.java:98)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.GLES20RecordingCanvas.<init>(GLES20RecordingCanvas.java:62)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.GLES20RecordingCanvas.<init>(GLES20RecordingCanvas.java:38)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.GLES20RecordingCanvas$1.newInstance(GLES20RecordingCanvas.java:46)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.GLES20RecordingCanvas$1.newInstance(GLES20RecordingCanvas.java:44)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.util.FinitePool.acquire(FinitePool.java:69)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.util.SynchronizedPool.acquire(SynchronizedPool.java:39)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.GLES20RecordingCanvas.obtain(GLES20RecordingCanvas.java:66)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.GLES20DisplayList.start(GLES20DisplayList.java:52)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10595)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.draw(View.java:11180)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10616)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.draw(View.java:11180)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10616)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10614)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10614)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.draw(View.java:11180)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.widget.FrameLayout.draw(FrameLayout.java:450)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10616)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10614)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10614)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10614)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10614)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10614)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.draw(View.java:11282)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.widget.FrameLayout.draw(FrameLayout.java:450)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.widget.ScrollView.draw(ScrollView.java:1788)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10616)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.draw(View.java:11180)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.support.v4.view.ViewPager.draw(ViewPager.java:1923)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10616)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.draw(View.java:11180)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10616)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.View.getDisplayList(View.java:10614)
10-13 10:42:56.910: E/AndroidRuntime(8089): at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
注意::这只发生在三星平板电脑2.0(Android版4.0.4)中。我还在nexus 7中检查过这个,但是它运行正常。
是否因为我在片段中动态地夸大布局并且布局存在缺陷或问题设备是否可靠?或者是另一个让我犯这种错误的问题?