java.lang.StackOverflowError:视图中的堆栈大小为8MB
发布时间:2020-12-15 04:37:55 所属栏目:Java 来源:网络整理
导读:这段代码导致我 java.lang.StackOverflowError:堆栈大小8MB错误,任何想法为什么?我想在NestedScrollView中使用TableLayout和TableRow. String testString = "test";tableLayout = (TableLayout) findViewById(R.id.tableLayout1);TextView textInRow = new
这段代码导致我
java.lang.StackOverflowError:堆栈大小8MB错误,任何想法为什么?我想在NestedScrollView中使用TableLayout和TableRow.
String testString = "test"; tableLayout = (TableLayout) findViewById(R.id.tableLayout1); TextView textInRow = new TextView(this) TableRow tableRow = new TableRow(this); textInRow.setText(testString); tableRow.addView(tableRow); tableLayout.addView(tableRow); 这是我的活动xml文件: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="eu.martinbednar.mayak.TripList" tools:showIn="@layout/activity_scrolling" android:id="@+id/table"> <TableLayout android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dip" android:isScrollContainer="true"> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TableRow> </TableLayout> </android.support.v4.widget.NestedScrollView> 谢谢你的帮助. 解决方法
很难说,但我猜这个
tableRow.addView(tableRow); 可能是原因.将视图添加到自身可能是无限递归的原因,因此是StackOverflowError (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读