简体   繁体   English

Android如何隐藏表格布局

[英]Android how to hide the table lyout

In my android application a love compatibility test is doing.. where first the details of boys and then details of girls are entered in the same page..one after another. 在我的android应用程序中进行爱兼容性测试..首先在同一页中输入男孩的详细信息,然后再输入女孩的详细信息。 and separate save button for saving boy details and girl details and these data is saved in separate databases. 单独的保存按钮,用于保存男孩和女孩的详细信息,这些数据保存在单独的数据库中。 and there is a recall button also there for both boys and girls. 还有一个针对男孩和女孩的召回按钮。 When this recall button is pressed the database will opened and from that user can select the name to be checked. 按下此调用按钮后,数据库将打开,该用户可以从中选择要检查的名称。 When he press the corresponding data has to be entered into the corresponding edittexts. 当他按下时,必须将相应的数据输入到相应的编辑文本中。 In my case I don't know how to close this tablerow. 就我而言,我不知道如何关闭此表行。 that mean the database opened.then only the data will go to the corresponding edittext box. 这意味着数据库已打开。然后只有数据将转到相应的edittext框。

I am giving my code below 我在下面给出我的代码

MainActivity 主要活动

btn4.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Cursor c = dbb.rawQuery("SELECT * from Data3", null);
            int count = c.getCount();
            c.moveToFirst();




            TableLayout tableLayout = new TableLayout(getApplicationContext());
            tableLayout.setVerticalScrollBarEnabled(true);
            TableRow tableRow;
            TextView textView1, textView2,textView3, textView4, textView5, textView6, textView7, textView8 ;
            tableRow = new TableRow(getApplicationContext());         
            textView1 = new TextView(getApplicationContext());
            textView1.setText("First Name");
            textView1.setTextColor(Color.BLACK);
            textView1.setTypeface(null, Typeface.BOLD);
            textView1.setPadding(20, 20, 20, 20);
            tableRow.addView(textView1);

            textView2 = new TextView(getApplicationContext());
            textView2.setText("Last Name");
            textView2.setTextColor(Color.RED);
            textView2.setTypeface(null, Typeface.BOLD);
            textView2.setPadding(10, 10, 10, 10);
            tableRow.addView(textView2);

            tableLayout.addView(tableRow);


            for(Integer j=0; j<count; j++)              
            {

                tableRow = new TableRow(getApplicationContext());

                textView3= new TextView(getApplicationContext());
                textView3.setText(c.getString(c.getColumnIndex("ffirstname")));
                textView3.setClickable(true);
                ett1=textView3.getText().toString();

                textView4 = new TextView(getApplicationContext());
                textView4.setText(c.getString(c.getColumnIndex("fmiddlename")));
                textView4.setClickable(true);
                ett2=textView4.getText().toString();


                textView5 = new TextView(getApplicationContext());
                textView5.setText(c.getString(c.getColumnIndex("flastname")));
                textView5.setClickable(true);
                ett3=textView5.getText().toString();


                textView6 = new TextView(getApplicationContext());
                textView6.setText(c.getString(c.getColumnIndex("fdayofbirth")));
                textView6.setClickable(true);
                ett4=textView6.getText().toString();


                textView7 = new TextView(getApplicationContext());
                textView7.setText(c.getString(c.getColumnIndex("fmonthofbirth")));
                textView7.setClickable(true);
                ett5=textView7.getText().toString();

                textView8 = new TextView(getApplicationContext());
                textView8.setText(c.getString(c.getColumnIndex("fyearofbirth")));
                textView8.setClickable(true);
                ett6=textView8.getText().toString();


                textView3.setPadding(10, 10, 10,10);
                textView5.setPadding(10, 10, 10, 10);
                tableRow.addView(textView3);
                tableRow.addView(textView5);
                tableLayout.addView(tableRow);
                c.moveToNext();

                final List<String> list = new ArrayList<String>();
                list.add(textView3.getText().toString());
                list.add(textView4.getText().toString());
                list.add(textView5.getText().toString());         
                list.add(textView6.getText().toString());
                list.add(textView7.getText().toString());         
                list.add(textView8.getText().toString());


                textView3.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {                           
                        // TODO Auto-generated method stub


                    }
                });



            }

            c.close();
            setContentView(tableLayout);
              dbb.close();

        }
    });

Declare the table layout out side button click and to make it GONE/INVISIBLE do Like this 声明表布局的侧面按钮单击并使其消失/不可见

 tablelayout.setVisibility(View.INVISIBLE);//white space will be available

Or 要么

 tablelayout.setVisibility(View.GONE);//No white space

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM