填充表并选择行以使用android进行编辑

时间:2012-07-26 03:08:19

标签: android database sqlite tablelayout

我在使用SQLite数据动态填充Android中的TABLE LAYOUT中的数据时遇到问题,并且在填充之后我希望这些行可以选择用于编辑该特定行中的信息。我想要的表的布局如下所示。

    ID|name|address|phone number|
     1| Peter|NYC   |1800-900000|
     2| Parker|LAC  |1900-909090|

我希望有人可以帮助我,因为我是Android编程的新手。

1 个答案:

答案 0 :(得分:0)

我想你打算根据你对andy的评论动态地添加表格行而不是表格布局。如果你想动态添加表行,那么你可以这样做.......

1) Create a table Layout under ur referring xml file. 
2) Refer to that table Layout in ur java code. say "table".
3) Then create a TableRow to add it to the TableLayout.
TableRow[] row = new TableRow(this);
TextView text = new TextView(this);
name.setText(// set ur text here);
row.addView(name);
4) Now finally add that tableRow to ur table.

table.addView(row);

类似地,你可以动态地添加到UR表中的行列。

所有你需要知道的是没有入口(表行)。然后开始循环。在循环结构中你将继续在表中添加行。

相关问题