0
我有一個listview顯示一個自定義行佈局,顯示一個Textview和2個EditTexts。 我在textview背景中顯示圖像,並在其上顯示文字。 在getView方法中,我異步加載圖像並顯示在列表視圖中。 列表視圖是否不爲可見的行調用getview方法?在列表視圖中正確顯示圖像
當我滾動textview包含不同的圖像,並獲取實際圖像,當它變得有點可見。爲什麼這種行爲顯示。因爲我沒有得到它更新。
public View getView(int arg0, View arg1, ViewGroup arg2) {
// TODO Auto-generated method stub
View v=arg1;
EditText t1,t2;
final TextView tv;
if (arg1 == null)
{ // if it's not recycled, initialize some attributes
LayoutInflater lf=(LayoutInflater)conn.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v=lf.inflate(R.layout.layitem,arg2,false);
}
tv = (TextView)v.findViewById(R.id.textView1);
LinearLayout.LayoutParams ll=new LinearLayout.LayoutParams(width,width/2); // setting width to same as that of mobile screen
ll.setMargins(10, 0, 10, 0);
tv.setLayoutParams(ll);
// tv.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
t1=(EditText)v.findViewById(R.id.editText1);
t2=(EditText)v.findViewById(R.id.editText2);
// here count is actual no of rows that have image loaded from server rest will have default background
if(arg0<count)
{
Bitmap object=loadimage(iurl[arg0]);
tv.setBackground(new BitmapDrawable(conn.getResources(),object));
tv.setText(texts[arg0]);
t1.setText(prays[arg0]);
}
else
{
tv.setBackgroundResource(R.drawable.wish);
tv.setText("");
t1.setText("0");
}
return v;
}
是緩存視圖,它們中的任何一個都表示查看任何位置。我們如何糾正它,使圖像變化的過渡不顯示。更新 – user2779311
您能顯示圖片加載代碼? – holtaf
您可以在getView()方法中的ImageView中設置一個虛擬圖像。準備就緒後,您的異步圖像將替換此圖像。 – Kuffs