gpt4 book ai didi

android - 为什么 view flipper 中出现 stackoverflow 错误?

转载 作者:行者123 更新时间:2023-11-29 02:09:47 32 4
gpt4 key购买 nike

我在 android 应用程序中使用 viewflipper。

我的应用程序在 tabhost 中有 tabhost。当我点击“主页”选项卡时——> 点击“节食”按钮——> 然后它会显示新的标签主机,例如早餐、午餐等。

当我在 lunch tab 中使用 view flipper 时,它有两个按钮 homeoffice 然后两个按钮通过 view flipper 切换布局,但是当午餐选项卡打开时它显示 stackoverflow 错误。

我也尝试了 layoutinflater 和其他选项期望 view flipper 但它显示相同的错误。

这是 logcat 错误

    11-16 10:08:48.229: ERROR/AndroidRuntime(223): Uncaught handler: thread main exiting due to uncaught exception
11-16 10:08:48.258: ERROR/AndroidRuntime(223): java.lang.StackOverflowError
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.text.Layout.measureText(Layout.java:1601)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.text.Layout.getLineMax(Layout.java:655)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.text.Layout.draw(Layout.java:311)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.text.BoringLayout.draw(BoringLayout.java:356)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.widget.TextView.onDraw(TextView.java:4032)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.widget.CompoundButton.onDraw(CompoundButton.java:229)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6274)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6277)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6277)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6380)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6277)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6277)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6277)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1524)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6277)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.drawChild(ViewGroup.java:1526)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1256)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View.draw(View.java:6277)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1883)
11-16 10:08:48.258: ERROR/AndroidRuntime(223): at android.view.View

代码在这里

    RelativeLayout rel1,rel2,rel3,rel4,rel5,rel6,
rel_Yes,rel_No;

ImageButton rad_Yes,rad_No;
TextView lbl_Yes,lbl_No;
boolean yesNoChk=false;
boolean have_lunch=false;

RelativeLayout flip1,flip2;

ViewFlipper vf;
StringBuffer pasta,rice,soup,legmues,l_pasta;

LinearLayout lin1;
int i,j;
ToggleButton [] imgArray1;
ToggleButton [] imgArray2;
ToggleButton [] imgArray3;
ToggleButton [] imgArray4;
ToggleButton [] imgArray5;
RelativeLayout item ;

Button btn;
StringBuffer msg;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.lunch);





rad_Yes = (ImageButton) findViewById(R.id.lunch_radio_office);
rad_No = (ImageButton) findViewById(R.id.lunch_radio_home);

vf = (ViewFlipper)findViewById(R.id.ViewFlipper01);

flip1=(RelativeLayout)findViewById(R.id.flip1);
flip2=(RelativeLayout)findViewById(R.id.flip2);

rad_Yes.setOnClickListener(yesClickListener);
rad_No.setOnClickListener(noClickListener);

item = (RelativeLayout)findViewById(R.id.main);
rel1 = (RelativeLayout) findViewById(R.id.main_rel1);
rel2 = (RelativeLayout) findViewById(R.id.main_rel2);
rel3 = (RelativeLayout) findViewById(R.id.main_rel3);
rel4 = (RelativeLayout) findViewById(R.id.main_rel4);
if(!yesNoChk)
{
rel5 = (RelativeLayout) findViewById(R.id.main_rel5);
}


imgArray1 = new ToggleButton[7];
for(j=0;j<imgArray1.length;j++)
{
imgArray1[j] = (ToggleButton) rel1.getChildAt(j);
imgArray1[j].setOnClickListener(this);

}

imgArray2 = new ToggleButton[7];
for(j=0;j<imgArray2.length;j++)
{
imgArray2[j] = (ToggleButton) rel2.getChildAt(j);
imgArray2[j].setOnClickListener(this);

}
imgArray3 = new ToggleButton[7];
for(j=0;j<imgArray3.length;j++)
{
imgArray3[j] = (ToggleButton) rel3.getChildAt(j);
imgArray3[j].setOnClickListener(this);

}
imgArray4 = new ToggleButton[7];
for(j=0;j<imgArray4.length;j++)
{
imgArray4[j] = (ToggleButton) rel4.getChildAt(j);
imgArray4[j].setOnClickListener(this);

}

if(!yesNoChk)
{
imgArray5 = new ToggleButton[7];
for(j=0;j<imgArray5.length;j++)
{
imgArray5[j] = (ToggleButton) rel5.getChildAt(j);
imgArray5[j].setOnClickListener(this);

}
}
}





OnClickListener yesClickListener = new OnClickListener() {
public void onClick(View v) {
if(!yesNoChk){
rad_Yes.setImageResource(R.drawable.selectradiobtn);
rad_No.setImageResource(R.drawable.radiobtn);
yesNoChk = true;


vf.getChildAt(1).setVisibility(View.VISIBLE);
vf.getChildAt(0).setVisibility(View.GONE);


}

}
};



OnClickListener noClickListener = new OnClickListener() {
public void onClick(View v) {

rad_No.setImageResource(R.drawable.selectradiobtn);
rad_Yes.setImageResource(R.drawable.radiobtn);
yesNoChk = false;

vf.getChildAt(0).setVisibility(View.VISIBLE);
vf.getChildAt(1).setVisibility(View.GONE);




}
};

最佳答案

哦!我明白了,我需要更改对我来说很容易的文本框值。因为我的布局在选项卡中的选项卡中。所以它无法清除堆栈,所以最好的方法是清除堆栈,然后替换我们想要的 TextView 的名称。

关于android - 为什么 view flipper 中出现 stackoverflow 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8146955/

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