我需要一些帮助,我正在使用查看器从动态阵列适配器显示。
我有列表视图。
每行包含 ;
- 标题(文本视图),
- 副标题(TextView),
- 进度条
- 下载按钮(按钮)。
单击下载按钮时,我想显示进度条并隐藏下载按钮。单击第一行的下载按钮时,显示第一个进度条,但也显示第 8 个进度条。
这是我的代码。我做错了什么?
public class TabInComingAdaptor extends BaseAdapter {
public static class ViewHolder {
TextView title;
TextView desc;
Button DownloadButton;
ProgressBar pB;
}
private ArrayList<rowObject> data;
private LayoutInflater inflater = null;
private Application ap;
// final private Activity currentActivity;
Button progressButton1;
int CurrentUser;
public TabInComingAdaptor(Activity activity, Application application,
ArrayList<rowObject> GelenFakslar) {
// currentActivity = activity;
ap = application;
data = GelenFakslar;
inflater = (LayoutInflater) ap
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View vi, ViewGroup parent) {
ViewHolder viewHolder;
if (vi == null) {
vi = inflater.inflate(R.layout.tab_incoming_row, parent, false);
viewHolder = new ViewHolder();
viewHolder.title = (TextView) vi.findViewById(R.id.RowTitle);
viewHolder.desc = (TextView) vi.findViewById(R.id.RowDesc);
viewHolder.DownloadButton = (Button) vi
.findViewById(R.id.RowDownloadButton);
viewHolder.pB = (ProgressBar) vi
.findViewById(R.id.RowDownloadProgress);
viewHolder.DownloadButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LinearLayout vwParentRow = (LinearLayout) v.getParent();
v.setVisibility(View.GONE);
ProgressBar zxcv = (ProgressBar) vwParentRow.getChildAt(0);
zxcv.setVisibility(View.VISIBLE);
vwParentRow.refreshDrawableState();
}
});
vi.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) vi.getTag();
}
viewHolder.title.setText(data.get(position).getBaslik());
viewHolder.desc.setText(data.get(position).getTarih());
return vi;
}
}