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用作这样的视图,显示在“警报”对话框中,

    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愿望中获取的数据显示了alertDialog上的所有文本视图以及从互联网获取的所有值,但是当我在Emulator或其他Android设备上运行它时,它说必须用上述logcat强制关闭,
如果有人知道解决方案,请帮助我。
提前致谢

编辑:

Details.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

10-07 23:12