【发布时间】:2014-01-22 05:01:42
【问题描述】:
这是像这样动态创建的相对布局视图:
... 所以我的问题是如何从这些动态元素中获取值并执行一些计算以在同样动态创建的 textview 上显示结果。 提前谢谢大家!!
public void goButtonClicked(View view) {
maalContainer.removeAllViews();
int numberofPlayersTolayout = (Integer) Integer.parseInt((String) numberOfPlayers.getSelectedItem());
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
for (int i = 0; i < numberofPlayersTolayout; i++) {
View dynamicEntryView = inflater.inflate(R.layout.player_entry_item, null);
maalContainer.addView(dynamicEntryView, params);
}
}
}
【问题讨论】:
-
将 Id 设置为
dynamicEntryView并保存所有 Id,然后使用dynamicEntryView的 Id 获取值
标签: android android-edittext android-relativelayout layout-inflater