<分区>
在我的 android 应用程序中,我需要根据按钮点击动态添加 subview 。我不知道该怎么做。我分享样本图像。如果有人知道请帮助我
<分区>
在我的 android 应用程序中,我需要根据按钮点击动态添加 subview 。我不知道该怎么做。我分享样本图像。如果有人知道请帮助我
最佳答案
我找到了问题的答案。对于每个按钮单击只是膨胀 xml desiged 布局。所以布局可以一个一个添加。代码在这里
LayoutInflater IInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
String[] names = { "Joe", "Jane", "Herkimer" };
while (run >= 1) {
View storeitems = IInflater.inflate(R.layout.product_child_item,
null);
productCode = (TextView) storeitems.findViewById(R.id.productCode);
productName = (TextView) storeitems.findViewById(R.id.productName);
noOfQuantity = (TextView) storeitems
.findViewById(R.id.noOfQuantity);
int i = run - 1;
productCode.setText(names[i]);
linearLayout.addView(storeitems, 0);
run--;
}
关于android - 在可扩展 ListView 中动态添加 subview 项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23781761/
相关文章:
android - 在子项的最后一项和下一个 Groupheader expandableListview 之间实现 Divider
android - ExpandableListView- 更新或删除特定行而不调用 Activity 中的适配器
android - 如何监控网络类型并在它发生变化时得到通知
android - 在 Android 的 fragment 中调用函数
android - 如何以编程方式创建具有所需背景颜色的 Drawable?
android - 在另一个 Activity 中使用来自一个 Activity 的方法
android - 抽屉导航中的 ExpandableListview