问题显示在表格布局动态行:机器人 [英] Problem to display dynamic rows in table layout : Android

查看:111
本文介绍了问题显示在表格布局动态行:机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示在表格布局的数据。数据数是动态的,所以我需要在表中实现动态行。为此,我想说明4 TextView的在一行。

I want to show data in table layout. Number of data is dynamic, so I need to implement dynamic rows in table. For this purpose I want to show 4 TextView in a single row.

问题

Problem

目前,我能够在桌子和四TextView中显示的数据,但我想所有四个的EditText之间的一些空间,但无法做到这一点。

Currently, I am able to show data in table and with four TextView, but I want some spaces between all four EditText, but unable to do it.

下面是我的code

for(ItemRow row : this.getRows()) {

                if(row != null) {
                    // delcare a new row
                    newRow = new TableRow(this);
                    newRow.setLayoutParams(new LayoutParams(
                            LayoutParams.FILL_PARENT,
                            LayoutParams.WRAP_CONTENT));
                    newRow.setPadding(0, 2, 0, 2);

                    column1 = new TextView(this);
                    column2 = new TextView(this);
                    column3 = new TextView(this);
                    column4 = new TextView(this);

                    column1.setTextColor(Color.BLACK);
                    column2.setTextColor(Color.BLACK);
                    column3.setTextColor(Color.BLACK);
                    column4.setTextColor(Color.BLACK);
                    column1.setSingleLine(false);
                    column2.setSingleLine(false);
                    column3.setSingleLine(false);
                    column4.setSingleLine(false);

                    if(row.getColumnOne() != null){
                        column1.setText(row.getColumnOne());
                    } 

                    if(row.getColumnTwo() != null) {
                        column2.setText(row.getColumnTwo());
                    }

                    if(row.getColumnThree() != null) {
                        column3.setText(row.getColumnThree());
                    }

                    if(row.getColumnFour() != null) {
                        column4.setText(row.getColumnFour());
                    }

                    //Now add a row 
                    newRow.addView(column1);
                    newRow.addView(column2);
                    newRow.addView(column3);
                    newRow.addView(column4);
                    //Add row to table
                    table.addView(newRow, new TableLayout.LayoutParams(
                            LayoutParams.FILL_PARENT,
                            LayoutParams.WRAP_CONTENT));
                }
            }

这是我的输出:

需要

Need

我需要的列之间的空格。我该怎么办呢?

I need spaces between columns. How can I do it?

推荐答案

每textveiw部件如 Android的设置填充左5DP:paddingLeft =5DP

Set padding left 5dp for every textveiw widget like android:paddingLeft="5dp"

这篇关于问题显示在表格布局动态行:机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆