简体   繁体   中英

How to hide a particular column in Android

I want to hide a column in Android TableRow ..because that data will be used on click of a particular row but not to show in table row.. in my following code I want to hide t3v column but As u can see I am using that data on click..

how to achieve that?

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

                    }
                });
            }

Try to Use setVisibility(View.GONE); like .

t3v.setVisibility(View.GONE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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