2012-05-10 11 views
0

このクラスは、最初だけ表示を確認する必要がありますbaseadapterなぜ画像が繰り返し表示され、リストビューに自動添付されるのですか?

public View getView(int position, View convertView, ViewGroup parent) { 
    if (!imagepath[position].toString().equals("no picture")) { 
     imageLoader.DisplayImage(imagepath[position], imageview); 
    } 
} 

public void DisplayImage(String url, ImageView imageView) { 
    imageViews.put(imageView, url); 
    Bitmap bitmap = memoryCache.get(url); 
    if (bitmap != null) { 
     imageView.setImageBitmap(bitmap); 
    } else { 
     queuePhoto(url, imageView); 
    } 
} 

と仮定最初のビューを拡張し、今確認した後に表示されます。

if (!imagepath[position].toString().equals("no picture")) { 

     titletext.setPadding(imageview.getWidth() + 5, 0, 0, 0); 
     datetext.setPadding(imageview.getWidth() + 5, 0, 0, 0); 
     imageview.setVisibility(View.VISIBLE); 
     imageLoader.DisplayImage(imagepath[position], imageview); 
    } else { 
     imageview.setVisibility(View.INVISIBLE); 
     imageview.setImageDrawable(null); 
     titletext.setPadding(0, 0, 0, 0); 
     datetext.setPadding(0, 0, 0, 0); 
    } 

    titletext.setText(title[position].toString()); 
    categorytext.setText(category[position].toString()); 
    datetext.setText(date[position].toString()); 

私はtextview setpaddingを最初に表示するだけではなく、もう一方の方法で表示します。

これを解決するにはどうすればよいですか?

+0

にも、カスタムアダプタのポストコード全体を他の条件を入れて、です。 if条件付きでelseを使用します。 – user370305

答えて

6

ListViewViewsを再使用していますので、それは

public View getView(int position, View convertView, ViewGroup parent) { 
    if (!imagepath[position].toString().equals("no picture")) { 
     imageLoader.DisplayImage(imagepath[position], imageview); 
    } 
    else{ 
     imageview.setImageResource(android.R.color.transparent); 
     // OR 
     imageview.setImageDrawable(null); 
    } 
} 
+0

+1素敵な答え:) – Lucifer

+0

いいえ、答えはいいですが、私の最初のアイテムのリストビューはまだ表示されずに –

+0

私はそれを解決しました –

関連する問題