我有一个在Android项目中以编程方式创建的TableLayout.只要从数据库中获取更多行,我就会不断添加TableRows.现在我想在TableRows之间添加分隔线,如边框.
在我从XML静态创建的另一个TableLayout中,我使用View作为分隔符,使用style.xml样式.
我尝试将一个View添加到tablelayout,如下所示:
View v=new View(this);
v.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
v.setBackgroundResource(R.drawable.rowseparator_shape);
tr.addView(mTvDate);
tr.addView(mTvResult);
tl.addView(tr);
tl.addView(v);
Run Code Online (Sandbox Code Playgroud)
但它只在所有收集的TableRows之后添加一次.为每个tr添加一个View的智能方法是什么?或者我应该一起使用其他东西?
嗨,我有一个tablelayoutpanel,我动态绑定控件.当项目数超过面板高度时,显然出现垂直滚动条没有问题.
但同时水平滚动条也出现,即使项目宽度小于面板的宽度.我该如何防止这种情况?
我正在创建一个布局如下,当我在AVD中模拟它时.它不会向下滚动以查看折叠下方的内容.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView android:text="@string/UserFormWelcome"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textSize="20px" android:gravity="center" />
<TextView android:text="@string/name" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textStyle="bold"
android:paddingTop="20px" android:paddingLeft="10px" />
<TableLayout android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TableRow android:layout_height="wrap_content"
android:layout_width="match_parent" android:paddingTop="20px">
<TextView android:text="@string/firstname"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:width="100px" android:paddingLeft="10px" />
<EditText android:id="@+id/LastName" android:width="200px"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView android:text="@string/lastname"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:paddingLeft="10px" />
<EditText android:id="@+id/LastName" android:width="200px"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
<TextView android:text="@string/dob" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textStyle="bold"
android:paddingTop="20px" android:paddingLeft="10px" />
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:stretchColumns="3"
android:paddingTop="20px" android:paddingLeft="10px">
<TableRow>
<TextView android:text="@string/date" android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) android scroll tablelayout android-layout android-linearlayout
快速提问,寻找一些建议.我有一个站点,它将从数据库请求数据并在表中显示回用户.我正在使用jQuery(AJAX),php和MySQL.
哪里是生成的HTML表格来显示数据的最佳场所:应在PHP生成并发送整个事情(HTML +数据)从服务器返回的,还是应该由PHP刚刚发回的数据,以及jQuery的代码制作表并插入数据?
虽然这是在内联网上运行,但我仍然更喜欢最快速的方法.
更新:
我想为这个主题添加一些额外的信息,以防它对其他人有用.我完全同意这里提出的分离想法,并将其作为我的设计方法.我使用PHP检索并将所需数据组织成JSON,然后使用jQuery生成HTML以显示返回的信息.在这种情况下,我使用jQuery创建了一个电子表格样式表格,并填充了具有从PHP返回的值的"单元格".有一些行和列,事情运行正常,但正如我增加说,一个16 x 16表,用jQuery动态创建输入元素...
在这一点上,我再一次遇到了丑恶的幽灵,即IE6.
IE6仍然是我工作的批准浏览器,所以我的应用程序必须在它上面运行.当我在Firefox和Opera上测试我的设计时,界面加载速度很快,很高兴使用.当我在IE6中运行相同的代码时,生成接口需要太长时间; 足够长的时间,我的用户会再次开始点击,认为应用程序没有响应.我只能将其归结为IE6中的JavaScript引擎,因为代码在较新的浏览器中运行良好.所以,正因为如此,我又重新设计了部分接口,让PHP至少生成内部表格元素,填充数据,然后将其发送回客户端.它打破了我想要的漂亮分离,但我没有看到任何其他方法来加速IE6中的客户端.
无论如何,只是认为其他人可能对这里的结果感兴趣,对于像我这样的其他初学者,有多少浏览器支持要求会影响设计选择.
我正在开发一个Android应用程序.
我有这个:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="200px"
android:orientation="vertical">
<TextView
android:id="@+id/gameTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="left"
android:layout_margin="5px"
android:text="aaaaa"/>
<TextView
android:id="@+id/gameDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="left"
android:layout_margin="5px"
android:typeface="sans"
android:textSize="16sp"
android:textStyle="bold"
android:text="dddddd"/>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ButtonsTable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:text="@string/yes"
android:id="@+id/playGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:text="@string/no"
android:id="@+id/noPlayGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想把playGame按钮放在中间的左侧,而noPlayGame按钮放在中间的右侧.
现在,两者都显示在TableRow的左侧.
我怎样才能做到这一点?
谢谢.
编辑:我添加了完整的布局和Ashay建议的修改.
第二次编辑:
解决方案
我已添加到TableLayout以下内容:android:stretchColumns="0,1".现在按钮是中心对齐的,但它们填满了他们的entiry列!
我正在为我的学位项目的最后一年项目创建一个侧滚动式游戏.
我只是想知道如何在手机处于水平方向显示时设计菜单,即使手机处于垂直方向?
即我希望用户知道游戏必须以手机的水平方向播放,并希望菜单只能以水平方向显示.
提前谢谢了.
我有一个项目需要一个包含固定宽度和灵活宽度列的表.
无论浏览器的宽度如何,有些列的宽度始终必须为80px.
其余的列需要是一个灵活的宽度,但宽度相等,最小宽度为75px;
通过添加table-layout:fixed; 在表格中我可以得到灵活的宽度cols都具有相等的宽度,但是表格忽略了td的min-width属性.
如果我删除了table-layout:fixed,则min-width有效但灵活的宽度cols都有不同的宽度(基于它们包含的文本的长度).
列数根据从db中提取的数据而变化.
我在表格布局中放了一个表格示例:jsfiddle上的固定和最小宽度:http://jsfiddle.net/7d2Uj/
任何想法如何让min-width在这种情况下工作,或者为什么会这样?
我正在显示一个表格布局,因为我想要在表格中的行之间分隔线.也可以在表格布局中进行列方式分离.请帮助我.
以下是我的xml表格布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="6dip"
android:paddingTop="4dip">
<TableLayout
android:id="@+id/tablelayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="2dip">
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Income"></TextView>
<TextView
android:layout_width="150px"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:text="Expense"></TextView>
</TableRow>
<TableRow android:layout_marginTop="30px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Household:"></TextView>
<TextView
android:id="@+id/text50"
android:layout_width="150px"
android:layout_height="wrap_content"
android:text="Household:"></TextView>
</TableRow>
<TableRow android:layout_marginTop="40px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="Travel:"></TextView>
<TextView
android:id="@+id/text51"
android:layout_width="150px"
android:layout_height="wrap_content"
android:layout_marginLeft="-250dp"
android:text="Travel"></TextView>
</TableRow>
<TableRow android:layout_marginTop="40px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="Education:"></TextView>
<TextView
android:id="@+id/text52"
android:layout_width="150px"
android:layout_height="wrap_content"
android:layout_marginLeft="-250dp"
android:text="Education"></TextView>
</TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用CheckBoxes网格创建一个TabeLayout.顶部是2个标题,每个附加行包含一个标签和2个CheckBoxes.我希望该表填充所有可用空间,第一列定向到左侧,CheckBoxes及其标题将在其列中居中.在下面的布局中,标题显示为正确居中,但CheckBox不是.我为其中一个CheckBox添加了一个背景颜色,这表明CheckBox实际上已经增长到填充它的列(这就是为什么它不会按照需要居中); 尽管有"wrap_content"布局参数.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<TableLayout
android:stretchColumns="1,2"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<TextView
android:text=""
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:text="First category"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView
android:text="2nd category"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</TableRow>
<TableRow>
<TextView
android:text="Row 1: "
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<CheckBox
android:background="#FF001122"
android:layout_height="50dip"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
</CheckBox>
<CheckBox
android:layout_height="50dip"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
</CheckBox>
</TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

void init()
{
intcolumnwidth1 = int_scr_wd*55;
intcolumnwidth1 = intcolumnwidth1/100;
for (int i = 0; i < strarr.length-1; i++)
{
strinarr = fun1.split(strarr[i].trim(),"^");
tr1 = (TableRow) new TableRow(this);
txt1=new TextView(this);
txt1.setWidth(intcolumnwidth1);
txt1.setText(strinarr[0]);
tr1.addView(txt1);
tl.addView(tr1,new TableLayout.LayoutParams(layoutParams));
}
}
Run Code Online (Sandbox Code Playgroud)
场景是这样的,当我第一次打开这个页面时,它动态地在表格布局中添加行...但是如果在一段时间后数据库中的数据发生变化...当我点击刷新按钮时,它会在旧数据之后附加新数据表格布局......我需要的是如何刷新或删除表格布局中已存在的textview的解决方案...
感谢名单..
tablelayout ×10
android ×7
c# ×1
css ×1
css-tables ×1
html ×1
javascript ×1
php ×1
scroll ×1
scrollbar ×1
separator ×1
textview ×1
winforms ×1