本文介绍了如何清除表格布局的previous内容是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个XML格式的表格布局。在运行时,我使用这样一种情况:在第一种情况下我正在填写表格的布局。然而,在第二种情况下我又添加内容相同的布局。而他们得到的布局年底相加。不过,我需要清晰的布局的previous内容。
我可以用这些removeallview()方法,它不工作..我的code作为

I have created a table layout in xml. At runtime, i am using a condition where in first case i am filling table layout. However in second case i am again adding contents to the same layout. And they get added up at the end of layout. However i need to clear the previous contents of layout.I can use these removeallview() method,It doesn't work.. my code as

ll=(LinearLayout)findViewById(R.id.linear1);

    for (int i = 0; i <= 1; i++) {

        table=new TableLayout(mContext);

        TableLayout.LayoutParams tableParams=  new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
        int leftMargin=0;
        int topMargin=0;
        int rightMargin=0;
        int bottomMargin=0;
        tableParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
        table.setLayoutParams(tableParams);

        lf_header = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        header_view = lf_header.inflate(R.layout.header, null);

        DBAdapter dbAdapter=DBAdapter.getDBAdapterInstance(this);
        try {
            dbAdapter.createDataBase();
        } catch (IOException e) {
            Log.i("*** select ",e.getMessage());
        }
        dbAdapter.openDataBase();
        if(i==0){
            ((TextView) header_view.findViewById(R.id.header_txt1)).setText("Over Due");
            header_view.setBackgroundColor(Color.RED);
            table.addView(header_view);
ll.addView(table);

任何建议??

例如:code是AP preciate ..

example code is appreciate..

在此先感谢..

推荐答案

尝试 table.removeAllViewsInLayout()

int count=table.getChildCount();
         for(int i=0;i<count;i++)
             table.removeView(layout.getChildAt(i));

这篇关于如何清除表格布局的previous内容是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 01:30