java. Lang. stackoverflowerror: the stack size in the view is 8MB
•
Java
This code leads me to Java Lang. stackoverflowerror: the stack size is 8MB. Why? I want to use tablelayout and tablerow in nestedscrollview
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);
This is my active XML file:
<?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>
Thanks for your help.
Solution
It's hard to say, but I guess this
tableRow.addView(tableRow);
It may be the reason Adding a view to itself may be the cause of infinite recursion, so it is stackoverflowerror
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码