我想要好像有人知道将1位图数组和2个字符串数组合并到列表数组的方法。根据拍摄的图像量动态创建位图和字符串数组。我之前使用以下代码创建了类似的东西,但没有动态图像或字符串。由于我不熟悉Arrays,如果有人能帮助我们完成细节,那将会非常好。真的很感激。
我知道它可以采取文字,但不知道如何转换arraylist将其添加为持有者中的字符串
ERROR LOG CAT-08-11 12:49:32.042:E / AndroidRuntime(19906):java.lang.ClassCastException:java.util.ArrayList无法强制转换为java.lang.CharSequence
主要活动
private List<String> Titles = new ArrayList<String>();
private List<String> Actions = new ArrayList<String>();
private List<Bitmap> Images = new ArrayList<Bitmap>();
static int x;
static int y=1;
static int z=1;
static int a=1;
while(y!=x){
String comment = commentresult();
// pdf = new File(root);
Titles.add(comment);
y++;
Log.d("y",new Integer(y).toString());
}
while(z!=x){
String act = actionresult();
Actions.add(act);
z++;
Log.d("z",new Integer(z).toString());}
while(a!=x){
Bitmap photo = getbitmap();
Images.add(photo);
a++;
Log.d("a",new Integer(a).toString());}
rowItems = new ArrayList<RowItem>();
RowItem item = new RowItem(Images, Titles,Actions);
rowItems.add(item);
listView = (ListView) findViewById(R.id.list);
CustomListAdapter adapter = new CustomListAdapter(this,
R.layout.aname_list_item, rowItems);
try {
listView.setAdapter(adapter); **Getting Error On this Part**
listView.setOnItemClickListener(this);
} catch (Exception e) {
System.out.println(e);}
}
RowItems
public class RowItem {
private List<Bitmap> imageId;
private List<String> title;
private List<String> desc;
public RowItem(List<Bitmap> images, List<String> titles, List<String> actions) {
this.imageId = images;
this.title = titles;
this.desc = actions;
}
public List<Bitmap> getImageId() {
return imageId;
}
public void setImageId(List<Bitmap> imageId) {
this.imageId = imageId;
}
public List<String> getDesc() {
return desc;
}
public void setDesc(List<String> desc) {
this.desc = desc;
}
public List<String> getTitle() {
return title;
}
public void setTitle(List<String> title) {
this.title = title;
}
@Override
public String toString() {
return title + "\n" + desc;
}
}
自定义列表适配器
private class ViewHolder {
ImageView imageView;
TextView txtTitle;
TextView txtDesc;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
RowItem rowItem = getItem(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.aname_list_item, null);
holder = new ViewHolder();
holder.txtDesc = (TextView) convertView.findViewById(R.id.desc);
holder.txtTitle = (TextView) convertView.findViewById(R.id.rab);
holder.imageView = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
holder.txtDesc.setText((CharSequence) rowItem.getDesc());
holder.txtTitle.setText((CharSequence) rowItem.getTitle());
// holder.imageView.setImageResource(rowItem.getImageId()); **Need help with this**
return convertView;
}
}