I have a ArrayAdapter which is populated using a POJO class. The listview comprises of 2 layout. 1 is for a menuitem and one is for the category. The Listview with seperator is
Within getView()
method you have to set tag to your button and when you click on button get the tag within integer, it will return you correct position of your button click, something like below.
else {
holder = (ViewHolder) convertView.getTag();
}
holder.edit.setTag(position); //to get the orignal position later in onClick() of button
holder.edit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int pos = (Integer) v.getTag(); //the real and updated position
Log.i("ConfirmAdapter ","Order Edit @ position : " + pos);
}
});
Updated
Note: after getting convert-view tag, set the tag to your button and handle click even too.
What is the main purpose of setTag() getTag() methods of View?