如何使用设置可见为动态创建的表格布局创建分页? [英] How to create a pagination for dynamically created table layout using set visible?
本文介绍了如何使用设置可见为动态创建的表格布局创建分页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从服务器获取数据并为该响应动态创建表格布局,现在每页只需要显示 5 行,我使用 setvisible(view.invisible)
来隐藏所有表格行,如何设置 5 行 setvisible(view.visible)
以显示分页之类的行?
I am getting data from server and create the tablelayout dynamically for that response, now I need to show only 5 rows per page, I am using setvisible(view.invisible)
to hide all the table rows, How to set the 5 rows setvisible(view.visible)
to show the rows like pagination ?
我用来动态创建表格的代码如下.
The code I used to create the table dynamically is below.
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);
推荐答案
试试 this,他们已经用示例代码解释了..
Try this, they have explained with example code..
这篇关于如何使用设置可见为动态创建的表格布局创建分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文