【发布时间】:2014-03-25 16:30:09
【问题描述】:
我正在从服务器获取数据并为该响应动态创建表格布局,现在我只需要每页显示 5 行,我正在使用 setvisible(view.invisible) 隐藏所有表格行,如何设置 5 行 @987654322 @ 显示分页之类的行?
我用来动态创建表格的代码如下。
TableLayout tableLayout = (TableLayout) findViewById(R.id.tablenew);
TableRow tableRow = new TableRow(this);
tableRow.setId(1);
tableRow.setBackgroundColor(Color.LTGRAY);
tableRow.setPadding(0,0,1,1);
tableRow.setLayoutParams(new TableLayout.LayoutParams());
tableRow.setVisibility(View.INVISIBLE);
TextView text = new TextView(this);
text.setText(name);
text.setBackgroundColor(Color.WHITE);
text.setPadding(5, 5, 5, 5);
text.setTextSize(30);
text.setLayoutParams(new TableRow.LayoutParams());
final Button button = new Button(this);
button.setPadding(5, 5, 5, 5);
button.setTextSize(30);
button.setTag(value);
button.setText("Install");
button.setLayoutParams(new TableRow.LayoutParams());
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
TableLayout tableLayout = (TableLayout) findViewById(R.id.tablenew);
final TableRow parent = (TableRow) v.getParent();
tableLayout.removeView(parent);
String id=(String) v.getTag();
}
});//button click listener
tableRow.addView(text);
tableRow.addView(button);
tableLayout.addView(tableRow);
【问题讨论】:
-
你要做什么?多解释一下
-
@MD - 我需要使用 setvisible(view.visible) 以编程方式使用行索引在每页显示 5 行。
-
@MD-最初我需要使用 setvisible(view.visible) 显示表的前 5 行,如果用户单击下一步按钮,则需要隐藏可见行并进行下一个可见 5 行。
-
请在此处发布您的 xml 文件
-
@jayesh 我正在以编程方式创建表格布局。不是通过 xml 文件
标签: android pagination android-tablelayout