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("https://stackoverflow.com/")+1, strPath.length());
showDialog(DIALOG_LOGIN);
}
});