我已经扩展了基本适配器——我遇到了一些奇怪的问题……当我滚动这个列表视图时——我的最后一项被第一项替换,下一次当我滚动时——另一个项目和所有……有时它是正确的。 .为什么它发生在这段代码中?
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// sets the view onto list view
LinearLayout rowLayout = null;
System.out.println("getView " + position + " " + convertView);
rowLayout = (LinearLayout) mInflater.inflate(
R.layout.apps_list_row_items, parent, false);
if (convertView == null) {
// inflating the row
vh.mAppIcon = (ImageView) rowLayout.findViewById(R.id.icon);
vh.mAppName = (TextView) rowLayout.findViewById(R.id.application);
vh.mAppHint = (TextView) rowLayout.findViewById(R.id.hint);
mDownloadButton = (Button) rowLayout.findViewById(R.id.download);
mDownloadButton.setFocusable(false);
} else {
// convertView.getTag();
rowLayout = (LinearLayout) convertView;
}
// convertView.getTag();
// On Click of the download button which triggers an async to download
// the file.
mIcon = mAppIconMapList.get(position);
System.out.println("Icon " + mIcon);
mCurrentApplication = mAvaiableApps.get(position);
System.out.println("Current App " + mCurrentApplication);
vh.mAppIcon.setImageBitmap(mIcon.get(mCurrentApplication));
vh.mAppName.setText(mCurrentApplication.replace(".apk", ""));
vh.mAppHint.setText("Click here to view Description");
return rowLayout;
}