我有一个应该显示X RelativeLayouts的活动,其中X是JSON数组的长度。我怎么能这样做?
到目前为止,我已经尝试过这个:
RelativeLayout[] interestLayouts = new RelativeLayout[jarr.length()];
for (int interest = 0; interest < jarr.length(); interest++) {
interestLayouts[interest] = (RelativeLayout) view.findViewById(R.id.X); // I don't know how to determine X
}
答案 0 :(得分:1)
您可以动态添加相对布局。
Linear LAYOUT; // suppose this is the layout where you want to add relativelayout
for (int i =0;i < jsonarray.length; i++){
Relative rLayout = new RelativeLayout(this);
LAYOUT.addView(rLayout);
}
类似这样的事情