Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误java.lang.IllegalStateException:指定的子级已具有父级。必须对子对象&x27;调用removeView();她先是父母_Java_Android - Fatal编程技术网

错误java.lang.IllegalStateException:指定的子级已具有父级。必须对子对象&x27;调用removeView();她先是父母

错误java.lang.IllegalStateException:指定的子级已具有父级。必须对子对象&x27;调用removeView();她先是父母,java,android,Java,Android,我想在onClick中向tablerow添加一个滚动视图我已经有了代码,但不幸的是它崩溃了,已停止java.lang.IllegalStateException:指定的子级已经有父级。我刚刚创建了一个GridView,当我单击GridView的项时,它显示了带有行的表布局,这是我的onClick代码 gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override

我想在onClick中向tablerow添加一个滚动视图我已经有了代码,但不幸的是它崩溃了,已停止java.lang.IllegalStateException:指定的子级已经有父级。我刚刚创建了一个GridView,当我单击GridView的项时,它显示了带有行的表布局,这是我的onClick代码

    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                long arg3) {
            // TODO Auto-generated method stub
            //Result tr
            String st = "insert into ChecksItems (Check_ID,Item_ID,QTY,UnitPrice,TotalPrice,DicountValue,Tax_Value,Adj_Value,NetPrice,Serial,Fired,Fired_Time,Voided,Voided_Time,Voided_Reason,P_On_Check,Complement,Status,IsModifier,Ref_Mod_Item,IsAssimbly,Ref_Ass_Item,Taxable,NoServiceCharge,Num_Fired,Num_Print,Server_ID,P_On_Report,Check_ID_Combine,Round_Check_Fired,Void_Effect_Invn,Promo_ID,Orig_Price,Officer,Comp_Reason_ID,End_Serial_Count,Discount_ID,Disc_Reason_ID,Hold,Hold_Time,Voided_By,Comp_By,Disc_By) values (" + String.valueOf(MenuListView.Check_ID) + "," + alphabets.get(arg2).get("Item_ID").toString() + ",1," + alphabets.get(arg2).get("Price").toString() + "," + alphabets.get(arg2).get("Price").toString() + ",0,0,0," + alphabets.get(arg2).get("Price").toString() + "," + String.valueOf(MenuListView.Item_Serial) + ",0,GetDate(),0,GetDate(),0,'" + alphabets.get(arg2).get("PrintOnChick").toString() + "',0,'New',0,0,0,0,'" + alphabets.get(arg2).get("Taxable").toString() + "','" + alphabets.get(arg2).get("NoServiceCharge").toString() + "',0,0,0,'" + alphabets.get(arg2).get("PrintOnReport").toString() + "',0,1,0,0," + alphabets.get(arg2).get("Price").toString() + ",0,0,0,0,0,0,GetDate(),0,0,0)";

            if (ConnectionClass.executeUpdate(st)) {
                MenuListView.Item_Serial++;
                final TableRow tr_head2 = new TableRow(GridDynamic.this);
                tr_head2.setId(10);
                tr_head2.setBackgroundDrawable(getResources().getDrawable(R.drawable.fab_label_background));
                tr_head2.setPadding(10, 10, 10, 10);
                tr_head2.setLayoutParams(new TableLayout.LayoutParams(
                        TableLayout.LayoutParams.FILL_PARENT,
                        TableLayout.LayoutParams.FILL_PARENT));

                TextView label_category2 = new TextView(GridDynamic.this);
                label_category2.setId(20);
                label_category2.setText("1");
                label_category2.setTextColor(Color.BLACK);
                label_category2.setTypeface(null, Typeface.BOLD_ITALIC);
                label_category2.setTextSize(18);
                label_category2.setPadding(20, 3, 20, 3);
                tr_head2.addView(label_category2);// add the column to the table row here

                TextView label_quantity_amount2 = new TextView(GridDynamic.this);
                label_quantity_amount2.setId(21);// define id that must be unique
                label_quantity_amount2.setText(alphabets.get(arg2).get("Name").toString()); // set the text for the header
                label_quantity_amount2.setTextColor(Color.BLACK); // set the color
                label_quantity_amount2.setTypeface(null, Typeface.BOLD_ITALIC);
                label_quantity_amount2.setTextSize(18);
                label_quantity_amount2.setPadding(20, 3, 20, 3); // set the padding (if required)
                tr_head2.addView(label_quantity_amount2); // add the column to the table row here

                TextView label_total_price_amount2 = new TextView(GridDynamic.this);
                label_total_price_amount2.setId(22);// define id that must be unique
                label_total_price_amount2.setText(alphabets.get(arg2).get("Price").toString()); // set the text for the header
                label_total_price_amount2.setTextColor(Color.BLACK); // set the color
                label_total_price_amount2.setTypeface(null, Typeface.BOLD_ITALIC);
                label_total_price_amount2.setTextSize(18);
                label_total_price_amount2.setPadding(20, 3, 20, 3); // set the padding (if required)
                tr_head2.addView(label_total_price_amount2); // add the column to the table row here

                tableLayout.addView(tr_head2, new TableLayout.LayoutParams(
                        TableLayout.LayoutParams.FILL_PARENT,
                        TableLayout.LayoutParams.WRAP_CONTENT));

            ScrollView scroll = new ScrollView(GridDynamic.this);
            scroll.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
                    TableRow.LayoutParams.FILL_PARENT));
            scroll.addView(tr_head2);
            scroll.removeAllViews();
            }

        }
    });
gridView.setOnItemClickListener(新的AdapterView.OnItemClickListener(){
@凌驾
公共链接(AdapterView arg0、视图arg1、内部arg2、,
长arg3){
//TODO自动生成的方法存根
//结果tr
String st=“插入到ChecksItems中(检查标识、项目标识、数量、单价、总价、折旧值、税额、调整值、净价、序列、解雇、解雇、解雇时间、作废、作废时间、作废原因、开机检查、补码、状态、修改器、参考修改项、分解、参考汇总项、应税、无服务费、解雇数量、打印数量、服务器标识、开机报告、检查标识组合、开机检查、作废、促销标识、促销)g_价格、官员、公司原因ID、结束系列计数、折扣ID、光盘原因ID、持有、持有时间、作废人、公司人、光盘人)值(“+String.valueOf(MenuListView.Check_ID)+”,“+alphabets.get(arg2).获取(“项目ID”).toString()+”,1,“+alphabets.get(arg2).获取(“价格”).toString(),“+alphabets.get(arg2).获取(“价格”).get(arg2).获取(“价格”).get+0,0,”+alphabets.get(arg2).get(“Price”).toString()+”,“+String.valueOf(MenuListView.Item_Serial)+”,0,GetDate(),0,GetDate(),0,”,“+alphabets.get(arg2).get(“PrintOnChick”).toString()+”,0,'New',0,0,0',“+alphabets.get(arg2).get(“应税”).toString()+”,“,“+alphabets.get(arg2).get(“noservice”).toString()”,0,0,+alphabets.get(arg2.get(“PrintOnReport”).toString()+”,0,1,0,0,“+alphabets.get(arg2.get(“Price”).toString()+”,0,0,0,0,0,GetDate(),0,0,0)”;
if(ConnectionClass.executeUpdate(st)){
MenuListView.Item_Serial++;
final TableRow tr_head2=新的TableRow(GridDynamic.this);
tr_head2.setId(10);
tr_head2.setBackgroundDrawable(getResources().getDrawable(R.drawable.fab_label_background));
tr_头2.设置填充(10,10,10,10);
tr_head2.setLayoutParams(新的TableLayout.LayoutParams(
TableLayout.LayoutParams.FILL\u父级,
TableLayout.LayoutParams.FILL_PARENT);
TextView label_category2=新的TextView(GridDynamic.this);
标签2.setId(20);
标签2.setText(“1”);
标签2.setTextColor(颜色为黑色);
label_category2.setTypeface(null,Typeface.BOLD_ITALIC);
标签2.SettexSize(18);
标签2.设置填充(20,3,20,3);
tr_head2.addView(label_category2);//在此处将列添加到表行中
TextView标签\数量\数量2=新的TextView(GridDynamic.this);
label_quantity_amount2.setId(21);//定义必须唯一的id
label_quantity_amount2.setText(alphabets.get(arg2.get(“Name”).toString());//设置标题的文本
label_quantity_amount2.setTextColor(Color.BLACK);//设置颜色
标签\数量\数量2.设置字体(空,字体.粗体\斜体);
标签\数量\数量2.设置尺寸(18);
label_quantity_amount2.setPadding(20,3,20,3);//设置填充(如果需要)
tr_head2.addView(label_quantity_amount2);//在此处将列添加到表行中
TextView标签\总价\金额2=新的TextView(GridDynamic.this);
label_total_price_amount2.setId(22);//定义必须唯一的id
label_total_price_amount2.setText(alphabets.get(arg2.get(“price”).toString());//设置标题的文本
label_total_price_amount2.setTextColor(Color.BLACK);//设置颜色
标签\总价\金额2.设置字体(空,字体,粗体\斜体);
标签总价格金额2.SettexSize(18);
label_total_price_amount2.设置填充(20,3,20,3);//设置填充(如果需要)
tr_head2.addView(label_total_price_amount2);//在此处将列添加到表行中
tableLayout.addView(tr_head2,新的tableLayout.LayoutParams(
TableLayout.LayoutParams.FILL\u父级,
TableLayout.LayoutParams.WRAP_CONTENT);
ScrollView scroll=新的ScrollView(GridDynamic.this);
scroll.setLayoutParams(新建TableRow.LayoutParams(TableRow.LayoutParams.FILL\u父级,
TableRow.LayoutParams.FILL_PARENT);
scroll.addView(tr_head2);
scroll.removeallview();
}
}
});