【发布时间】:2016-11-09 09:55:06
【问题描述】:
我正在使用 sax xml parsing 并使用模型类将数据存储到 array list。
在此基础上,我正在动态生成buttons。
这是xml 数据。
<SalesLocation>
<SalesLocationGroup>0</SalesLocationGroup>
</SalesLocation>
<SalesLocation>
<SalesLocationGroup>0</SalesLocationGroup>
</SalesLocation>
<SalesLocation>
<SalesLocationGroup>1</SalesLocationGroup>
</SalesLocation>
<SalesLocation>
<SalesLocationGroup>2</SalesLocationGroup>
</SalesLocation>
<SalesLocation>
<SalesLocationGroup>3</SalesLocationGroup>
</SalesLocation>
<SalesLocation>
<SalesLocationGroup>4</SalesLocationGroup>
</SalesLocation>
现在在Sales Location Group Value 的基础上使用上面的xml 我正在向Linear Layout 添加按钮。
private ArrayList<ModelSalesLocation> arrayListSalesLocation;
final Button tableButton = new Button(this);
tableButton.setId(iTable);
tableButton.setText(arrayListSalesLocation.get(iTable).getSalesLocationName());
final LinearLayout.LayoutParams linearParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
if (arrayListSalesLocation.get(iTable).getSalesLocationGroup().equals("0")) {
int wd = ((Integer.parseInt(arrayListSalesLocation.get(iTable).getTableWidth()) * deviceWidth) / 1080);
Log.w("Final Width", "" + wd);
linearParams.width = wd;
int ht = ((Integer.parseInt(arrayListSalesLocation.get(iTable).getTableHeight()) * deviceHeight) / 1776);
Log.w("Final Height", "" + ht);
linearParams.height = ht;
int top = ((Integer.parseInt(arrayListSalesLocation.get(iTable).getTopLocation()) * deviceHeight) / 1776);
Log.w("Final Top", "" + top);
linearParams.topMargin = top;
int left = ((Integer.parseInt(arrayListSalesLocation.get(iTable).getLeftLocation()) * deviceWidth) / 1080);
Log.w("Final Left", "" + left);
linearParams.leftMargin = left;
linearTableMain.addView(tableButton, linearParams);
}
现在如果Sales Location Group 包含 0 多次等等,那么我需要将它添加到同一索引上的数组列表中。
目前我在不同的索引上获得两个值。
如何在同一索引处添加多个值并在此基础上显示按钮。
如果您需要这方面的更多信息,请告诉我。
提前致谢。
【问题讨论】:
标签: android android-studio arraylist saxparser