【发布时间】:2017-08-25 04:29:22
【问题描述】:
我正在开发一个应用程序,我需要根据字符串变量中保存的值生成ImageViews。
例如,如果String strNoOfImages = 2,则应在布局内生成 2 个图像视图。
请看下面的代码:
for (int i=0; i < resultArray.length; i++){
String strElemnet = resultArray[i].toString();
strNoOfImages = strElemnet.split(";")[2]; // NO OF IMAGES AT INDEX 2 OF ARRAY
strHeadings = strElemnet.split(";")[1]; // HEADINGS AT INDEX 1 OF ARRAY
if(strNoOfImages != null){
// is this a write method?
// if yes, what should i write here?
}
}
'strNoOfImages' 包含一个值,如 2,3 或任何其他数字。我只想根据'strNoOfImages'中的值生成图像视图。
另外,我想知道我是否也必须在activity_mail.xml 中创建imageView?
如有任何解决方案,请回复。
提前致谢。
【问题讨论】:
标签: java android arrays android-layout listview