2012-09-11 21 views
-1

我有列表视图,并且在每行必须是图像的hoeizontal滚动视图女巫N多,而其只是不断尽快崩溃我的应用程序,因为我开始这一活动Android的列表视图不会加载图像

这里是代码

public View getView(int position, View convertView, ViewGroup parent) { 

    View vi=convertView; 
    if(convertView==null){ 
     vi = inflater.inflate(R.layout.foto_list_row, null); 
    } 


    TextView title = (TextView)vi.findViewById(R.id.foto_title); // title 


    HashMap<String, String> n = new HashMap<String, String>(); 
    n = data.get(position); 
    LinearLayout ll = (LinearLayout) vi.findViewById(R.id.fotoh); 
    String var[] = (n.get(FotoView.TAG_ALBUM)).split(","); 
    ImageView iv = new ImageView(activity.getApplicationContext()); 
    for(int a=0;a<var.length;a++){ 
     String t = var[a]; 
     if(t == "null"){ 
      t.replace("null", ""); 
     }else{ 
      //tv.setText(t); 
      imageLoader.DisplayImage(t,iv); 
      ll.addView(iv); 
     } 
    } 


    // Setting all values in listview 
    title.setText(n.get(FotoView.TAG_TITLE)); 
    return vi; 
} 
+1

请添加logcat。 – rahul

+0

问题与您的适配器... – Shiva

回答

1

列表类型创建自定义适配器我想你可能想要的是有一个xml布局文件图库,并且该文件将用作ListView行和您需要在当前的getView()中为Gallery创建另一个适配器,您需要执行此操作。

public View getView(int position, View convertView, ViewGroup parent) 
{ 
    Gallery gallery; 
    if (convertView == null) 
     gallery == inflater.inflate(R.layout.gallery_row, parent, false); 
    else 
     gallery == (Gallery) convertView; 

    String[] images = data.get(position).split(","); 
    GalleryAdapter gAdapter = new GalleryAdapter(images); 
    gallery.setAdapter(gAdapter); 

    return gallery; 

} 

我认为,你可以有一个基本的想法,你应该做的。

0

只是搜索“列表视图中的世界”,在谷歌,你会得到回答如何在Android的