如何隐藏Android

时间:2016-07-11 08:57:13

标签: java android android-tablelayout

我想在Android TableRow中隐藏一列...因为该数据将用于点击特定行但不显示在表格行中。 在我的下面的代码中,我想隐藏t3v列但是你可以看到我在点击时使用了这些数据..

如何实现?

 TableLayout stk = (TableLayout) findViewById(R.id.data_cells);
    TableRow tbrow0 = new TableRow(this);
    TextView tv0 = new TextView(this);
for (FileListDTO rec : recordingListResponseDTO.getFileList()) {

                TableRow tbrow = new TableRow(this);
                tbrow.setClickable(true);
                TextView t1v = new TextView(this);
                t1v.setText("" +rec.getCamname());
                t1v.setTextColor(Color.WHITE);
                t1v.setGravity(Gravity.CENTER);
                tbrow.addView(t1v);

                TextView t2v = new TextView(this);
                t2v.setText("" +rec.getEnd());
                t2v.setTextColor(Color.WHITE);
                t2v.setGravity(Gravity.CENTER);
                tbrow.addView(t2v);
                TextView t3v = new TextView(this);
                t3v.setText("" + rec.getRecReason());
                t3v.setTextColor(Color.WHITE);
                t3v.setGravity(Gravity.CENTER);
                tbrow.addView(t3v));

                stk.addView(tbrow);
                tbrow.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        v.setBackgroundColor(Color.GRAY);
                        TableRow t = (TableRow) v;
                        TextView firstTextView = (TextView) t.getChildAt(0);
                        TextView secondTextView = (TextView) t.getChildAt(2);
                        String firstText = firstTextView.getText().toString();
                        String secondText = secondTextView.getText().toString();
                        System.out.println("Row clicked: " + secondText);

                    }
                });
            }

1 个答案:

答案 0 :(得分:3)

尝试使用setVisibility(View.GONE);之类的。

t3v.setVisibility(View.GONE);