gpt4 book ai didi

部分android设备出现java.lang.StackOverflowError异常

转载 作者:行者123 更新时间:2023-11-30 09:09:41 27 4
gpt4 key购买 nike

1181-1181/com.national.nhl E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.national.nhl, PID: 1181
java.lang.StackOverflowError
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5712)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)
at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5714)

我已经使用 Tablelayout 作为显示在警告对话框上的 View ,如下所示,

    rowLink=(TableLayout)getLayoutInflater().inflate(R.layout.details, null);
rowLink.addView(rowLink);
((ViewGroup)rowLink.getParent()).removeView(rowLink);


tvrgp=(TextView)rowLink.findViewById(R.id.tvrgp);
tvrg=(TextView)rowLink.findViewById(R.id.tvrg);
tvra=(TextView)rowLink.findViewById(R.id.tvra);
tvrp=(TextView)rowLink.findViewById(R.id.tvrp);
tvrplusminus=(TextView)rowLink.findViewById(R.id.tvrplusminus);
tvrpim=(TextView)rowLink.findViewById(R.id.tvrpim);
try{
Document doc = Jsoup.connect(temp).get(); //temp is url of webiste
Element regularseason = doc.getElementsByTag("table").get(3);
Elements tbody=regularseason.select("tbody");
Elements row = tbody.select("tr");
Element vrgp = row.select("td").get(1);
Element vrg = row.select("td").get(2);
Element vra = row.select("td").get(3);
Element vrp = row.select("td").get(4);
Element vrplusminus=row.select("td").get(5);
Element vrpim = row.select("td").get(6);

tvrgp.setText(vrgp.text().trim());
tvrg.setText(vrg.text().trim());
tvra.setText(vra.text().trim());
tvrp.setText(vrp.text().trim());
tvrplusminus.setText(vrplusminus.text().trim());
tvrpim.setText(vrpim.text().trim());

}catch(Exception ex)
{ ex.printStackTrace();}




new AlertDialog.Builder(LineUps.this)
.setTitle("player")
.setView(rowLink)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {

}
}).show();

它在我的 htc desire s 中获取数据显示了 alertDialog 上的所有 TextView 以及从互联网获取的所有值,但是当我在模拟器或其他 Android 设备上运行它时,它说用上面的 logcat 强制关闭,如果有人知道解决方案,请帮助我。提前致谢

编辑:

详细信息.xml

android:id="@+id/row1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:textColor="#FFFFFF"
android:id="@+id/statistics"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="18dp"
android:background="#010101"
android:gravity="center"
android:padding="2dp"
android:layout_span="3"></TextView>

android:id="@+id/row2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:background="#010101"
android:textColor="#FFFFFF"
android:id="@+id/titlenew"
android:text=""
android:gravity="center"
android:textStyle="bold"
android:typeface="serif"
android:padding="4dp"
android:layout_margin="1dp">

</TextView>
<TextView
android:layout_margin="1dp"

android:textColor="#FFFFFF"
android:text="REGULAR SEASON"
android:id="@+id/titleregular"

android:textStyle="bold"

android:layout_width="wrap_content"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"

android:textColor="#FFFFFF"
android:text="LEAGUE RANK"
android:id="@+id/titleleague"
android:textStyle="bold"

android:layout_width="wrap_content"
android:background="#010101"
android:padding="4dp"></TextView>

android:id="@+id/row3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">




<TextView

android:textColor="#FFFFFF"
android:id="@+id/titlegp"
android:text="GP"
android:gravity="center"
android:textStyle="bold"
android:layout_margin="1dp"
android:typeface="serif"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:id="@+id/tvrgp"

android:textStyle="bold"
android:gravity="center_horizontal"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvlgp"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>

android:id="@+id/row4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">



<TextView

android:textColor="#FFFFFF"
android:id="@+id/titleg"
android:text="G"
android:layout_margin="1dp"
android:gravity="center"
android:textStyle="bold"
android:typeface="serif"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"

android:textStyle="bold"
android:id="@+id/tvrg"
android:gravity="center_horizontal"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvlg"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>

android:id="@+id/row5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_margin="1dp"

android:textColor="#FFFFFF"
android:id="@+id/titlea"
android:gravity="center"
android:text="A"
android:textStyle="bold"
android:typeface="serif"
android:background="#010101"
android:padding="4dp"></TextView>

<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"

android:textStyle="bold"
android:id="@+id/tvra"
android:gravity="center_horizontal"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView

android:textColor="#FFFFFF"
android:layout_margin="1dp"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvla"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>

android:id="@+id/row6"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_margin="1dp"

android:textColor="#FFFFFF"
android:id="@+id/titlep"
android:text="P"
android:gravity="center"
android:textStyle="bold"
android:typeface="serif"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvrp"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvlp"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>

android:id="@+id/row7"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_margin="1dp"

android:textColor="#FFFFFF"
android:id="@+id/titleplusminus"
android:text="+/-"
android:gravity="center"
android:textStyle="bold"
android:typeface="serif"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvrplusminus"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvlplusminus"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>

android:id="@+id/row8"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_margin="1dp"

android:textColor="#FFFFFF"
android:text="PIM"
android:id="@+id/titlepim"
android:gravity="center"
android:textStyle="bold"
android:typeface="serif"
android:background="#010101"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvrpim"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>
<TextView
android:layout_margin="1dp"
android:textColor="#FFFFFF"
android:background="#010101"
android:textStyle="bold"
android:id="@+id/tvlpim"
android:gravity="center_horizontal"
android:padding="4dp"></TextView>




</TableRow>

最佳答案

我觉得问题出在这里:

rowLink.addView(rowLink);
((ViewGroup)rowLink.getParent()).removeView(rowLink);

看起来像按照此代码创建循环依赖,这就是为什么您会收到 StackOverflow 错误。您应该有 2 个单独的 Views:第一个用于容器,第二个用于内容。 TableLayout 应该包含 TableRows,例如可以包含 TextViews

关于部分android设备出现java.lang.StackOverflowError异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22955312/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com