2012-09-11 38 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的