簡體   English   中英

Android如何隱藏表格布局

[英]Android how to hide the table lyout

在我的android應用程序中進行愛兼容性測試..首先在同一頁中輸入男孩的詳細信息,然后再輸入女孩的詳細信息。 單獨的保存按鈕,用於保存男孩和女孩的詳細信息,這些數據保存在單獨的數據庫中。 還有一個針對男孩和女孩的召回按鈕。 按下此調用按鈕后,數據庫將打開,該用戶可以從中選擇要檢查的名稱。 當他按下時,必須將相應的數據輸入到相應的編輯文本中。 就我而言,我不知道如何關閉此表行。 這意味着數據庫已打開。然后只有數據將轉到相應的edittext框。

我在下面給出我的代碼

主要活動

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();

        }
    });

聲明表布局的側面按鈕單擊並使其消失/不可見

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

要么

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM