0

正如在其他一些线程中提到的,我在从我的 BaseAdapter 的 Textview 中设置文本时遇到了麻烦。

每当我尝试在其中设置希伯来语字符串时,我都会收到 stackoverflow 错误.. 设置英文字符串时 - 完美运行我试图找出错误的确切位置,所以我已经分解了我的每一段代码这就是我发现的:当我的文本视图嵌套在新视图中时 - 出现 stackoverflow..

在这个 XML 中有 stackoverflow(仅在希伯来语字符串中):

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TableRow>

        <include
            android:layout_width="45dp"
            android:layout_height="45dp"
            android:layout_gravity="center_vertical"
            android:layout_margin="4dp"
            layout="@layout/list_profile_picture_green"
            android:padding="4dp" />

        <TableLayout android:layout_width="match_parent"
            android:layout_height="match_parent">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

        </TableLayout>

    </TableRow>

</TableLayout>

这个 XML 完美地显示了希伯来语:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TableRow>

        <include
            android:layout_width="45dp"
            android:layout_height="45dp"
            android:layout_gravity="center_vertical"
            android:layout_margin="4dp"
            layout="@layout/list_profile_picture_green"
            android:padding="4dp" />



        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />


    </TableRow>

</TableLayout>

这是我的堆栈跟踪:

06-24 00:48:02.565: E/AndroidRuntime(20483): FATAL EXCEPTION: main
06-24 00:48:02.565: E/AndroidRuntime(20483): java.lang.StackOverflowError
06-24 00:48:02.565: E/AndroidRuntime(20483):    at java.lang.StringBuilder.append(StringBuilder.java:312)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at java.lang.StringBuilder.append(StringBuilder.java:44)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at java.util.Formatter.outputCharSequence(Formatter.java:1114)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at java.util.Formatter.doFormat(Formatter.java:1086)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at java.util.Formatter.format(Formatter.java:1062)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at java.util.Formatter.format(Formatter.java:1031)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at java.lang.String.format(String.java:2183)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at java.lang.String.format(String.java:2157)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.text.Styled.drawDirectionalRun(Styled.java:266)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.text.Styled.drawText(Styled.java:362)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.text.Layout.drawText(Layout.java:1546)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.text.Layout.draw(Layout.java:380)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.TextView.onDraw(TextView.java:4417)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.View.draw(View.java:6933)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.AbsListView.dispatchDraw(AbsListView.java:1648)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.ListView.dispatchDraw(ListView.java:3217)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.View.draw(View.java:6936)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.AbsListView.draw(AbsListView.java:3030)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.View.draw(View.java:6936)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.FrameLayout.draw(FrameLayout.java:357)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.View.draw(View.java:6936)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.FrameLayout.draw(FrameLayout.java:357)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.View.draw(View.java:6936)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.FrameLayout.draw(FrameLayout.java:357)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.View.draw(View.java:6936)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.FrameLayout.draw(FrameLayout.java:357)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.view.View.draw(View.java:6936)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at android.widget.FrameLayout.draw(FrameLayout.java:357)
06-24 00:48:02.565: E/AndroidRuntime(20483):    at com.android.internal.policy.impl.P

知道为什么吗???

4

1 回答 1

0

文本本身没有错误。当使用这个确切的代码(没有include)时,我在英语和希伯来语上都没有错误,无论是 XML 布局。

这里的问题是你有太多的嵌套布局。我怀疑这TableLayout包含在其他东西中,来自其他东西,等等......

您必须减少嵌套布局的数量;我怀疑这显示为StackOverflow错误的原因是因为希伯来语从右到左读取并且还占用了更多空间来表示,所以这就是将内存推到极限的原因。

我相信您在此处此处列出了相同的问题。

减少您拥有的嵌套布局项目的数量,这应该会消失。(例如,作为一般做法,a TableLayoutwithin anotherTableLayout是不好的做法。)可能会有所帮助。

于 2012-06-23T22:28:29.663 回答