Showing status for the last list item in a ListView using ViewHolder Showing status for the last list item in a ListView using ViewHolder android android

Showing status for the last list item in a ListView using ViewHolder


Issue is in holder.dataImageButton.setOnClickListener method block, position value you are assigning to globalPosition (globalPosition = position;) is the one passed to getView method (getView is called every time view is recycled). So you should set position to holder.dataImageButton tag and retrieve from it inside your setOnClickListener method block.

So set the position in holder.dataImageButton tag

holder.dataImageButton.setTag(position);

after your code line

holder.dataImageView.setImageResource(R.drawable.bullet_button);

and modify your setOnClickListener method as

holder.dataImageButton.setOnClickListener(new View.OnClickListener() {    @SuppressWarnings("deprecation")    public void onClick(View v) {        // Print        globalPosition = (Integer)v.getTag(); //modified        fileName=ImageList.get(position).toString().substring                            (strPath.lastIndexOf('_')+1, strPath.length());        fileNameDB=ImageList.get(position).toString().substring                            (strPath.lastIndexOf('/')+1, strPath.length());        showDialog(DIALOG_LOGIN);    }});


It appears that in both UploadData and UploadBulkData the exact same code is used for updating the uploaded database: myDbbv.InsertData(fileNameDB). This would have the effect of only marking the last file of UploadBulkData as being uploaded, which is consistent with the problematic behavior you are seeing.

Try updating myDbbv for each file being uploaded in UploadData and see if it helps.