TabWidgets、ListView 等导致 stackoverflow

发布于 2024-12-20 02:03:20 字数 4646 浏览 2 评论 0原文

我创建了一个应用程序,一个相当复杂的应用程序。主类是一个 tabhost,其中包含 3 个其他 tabhost 作为小部件。某些 tabwidgets 包含 listviews,并且其中一个列表导致出现 stackoverflow 错误。

但这种错误仅发生在姜饼上(并非所有设备上)。我真的不知道如何摆脱这个错误。

在此之前,我在 listview 中的每个项目中有 3-4 个 线性布局,但现在我得到了一个 relativelayout,而不是这个。这有帮助,但只持续了一段时间。

怎么可能一个应用程序运行良好,而另一个应用程序却不断崩溃?

java.lang.StackOverflowError
at android.widget.TextView.onDraw(TextView.java:4321)
at android.view.View.draw(View.java:6970)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.view.View.buildDrawingCache(View.java:6695)
at android.view.View.getDrawingCache(View.java:6475)
at android.view.ViewGroup.drawChild(ViewGroup.java:1657)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.widget.AbsListView.dispatchDraw(AbsListView.java:1480)
at android.widget.ListView.dispatchDraw(ListView.java:3193)
at android.view.View.draw(View.java:6973)
at android.widget.AbsListView.draw(AbsListView.java:2588)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1961)
at android.view.ViewRoot.draw(ViewRoot.java:1600)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1321)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1957)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4263)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

I've created an app, a quite complex one. The main class is a tabhost, which contains 3 other tabhosts as a widgets. Some tabwidgets contains listviews, and one of the lists is causing a problems with a stackoverflow error.

But this kind of error only occurs on gingerbread (not on all devices). I really don't know how to get rid off this error.

Before this I had 3-4 linearlayouts in each item in listview, but now I instead of this I got a relativelayout. This helped, but only for a while.

How is possible that one app is working fine, and another is just constantly crashing?

java.lang.StackOverflowError
at android.widget.TextView.onDraw(TextView.java:4321)
at android.view.View.draw(View.java:6970)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.view.View.buildDrawingCache(View.java:6695)
at android.view.View.getDrawingCache(View.java:6475)
at android.view.ViewGroup.drawChild(ViewGroup.java:1657)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.widget.AbsListView.dispatchDraw(AbsListView.java:1480)
at android.widget.ListView.dispatchDraw(ListView.java:3193)
at android.view.View.draw(View.java:6973)
at android.widget.AbsListView.draw(AbsListView.java:2588)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.ViewGroup.drawChild(ViewGroup.java:1730)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1732)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459)
at android.view.View.draw(View.java:6973)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1961)
at android.view.ViewRoot.draw(ViewRoot.java:1600)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1321)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1957)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4263)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云醉月微眠 2024-12-27 02:03:20

我在使用 ListView 的行时遇到了同样的问题,如下所示的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<FrameLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#FFE60000">

    <TextView android:id="@+id/header_category_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Category goes here..."
        android:padding="1dp"
        style="@style/offers_group_category">
    </TextView>

</FrameLayout>

<FrameLayout android:id="@+id/container_flipper"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <ViewFlipper android:id="@+id/flipper"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

    </ViewFlipper>

</FrameLayout>

<LinearLayout
    android:id="@+id/container_dots"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginBottom="2dp"
    android:gravity="center"
    android:orientation="horizontal" >

    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/im_dot_full"
    />
    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/im_dot_empty"
    />

</LinearLayout>

正如你所看到的,我在 FrameLayout 中有一个 ViewFlipper,它在我测试过的几乎所有设备上都运行良好,但它在 HTC Wildfire S 等(所有带有 Ghingerbread 的手机)中崩溃了。所以就我而言,解决方案是从 FrameLayout 中取出 ViewFlipper。
希望它能帮助你。

I had the same problem using a row for ListView like bellow layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<FrameLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#FFE60000">

    <TextView android:id="@+id/header_category_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Category goes here..."
        android:padding="1dp"
        style="@style/offers_group_category">
    </TextView>

</FrameLayout>

<FrameLayout android:id="@+id/container_flipper"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <ViewFlipper android:id="@+id/flipper"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

    </ViewFlipper>

</FrameLayout>

<LinearLayout
    android:id="@+id/container_dots"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginBottom="2dp"
    android:gravity="center"
    android:orientation="horizontal" >

    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/im_dot_full"
    />
    <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/im_dot_empty"
    />

</LinearLayout>

As you can see I had a ViewFlipper inside FrameLayout, that was working good in almost of devices I tested it, but it was crashing in HTC Wildfire S for instance (All phones with Ghingerbread). So in my case the solution was to take out ViewFlipper from FrameLayout.
Hope it will help you.

任谁 2024-12-27 02:03:20

从堆栈跟踪看来,某些代码块正在递归调用 android.view.View.draw 方法,请发布您的代码以获取更多详细信息

From the stack-trace it seems that some block of code is recursively calling the android.view.View.draw method, please post your code for more details

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文