我正在使用線程加載圖像在我的getadget()我的BaseAdapter類。但圖像加載不正常..當我滾動listview圖像正在改變..同名圖像即將有些職位......幫我解決這個問題。線程在列表視圖中加載圖像
這是我的getview代碼:
public View getView(int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
// View listView = convertView;
Position=position;
ViewHolder holder;
Thread thread = new Thread()
{
public void run()
{
bitmap= DownloadImage(
kickerimage[Position]);
}
};
thread.start();
// Bitmap bitmap= DownloadImage(
// kickerimage[position]);
if (convertView == null)
{
//this should only ever run if you do not get a view back
LayoutInflater inflater = (LayoutInflater) contxt
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.homelistrow, null);
holder = new ViewHolder();
holder.image = (ImageView) convertView
.findViewById(R.id.icon);
holder.text = (TextView) convertView
.findViewById(R.id.name_label);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
//
holder.image.setImageBitmap(bitmap);
//// items=itemsarray[position];
holder.text.setText(itemsarray[position]);
return convertview
}
把你的線程進入的if else塊 – Yahor10
使用的AsyncTask代替線程你的App –
由於更好的性能Yahor10..I是新來這個概念..你可以提供更多的細節? – Subburaj