Sorry for my English, I use Google translator. There is ListView. There is an event handler AdapterView.OnItemClickListener (). Inside it is changing the layout of the ListItem and appointed handlers onClick imageviev. The following code passes the point.
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> parent, View view, final int position, long id) {
... Here we change the layout
/**
* Bind the event handlers for new control
*/
// Get UI-control
ImageView photoCapture = (ImageView) newInnerView.findViewById(R.id.listview_element_report_row_imageview);
// set handler
photoCapture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCurrentItemPosition = position; ///??????????
...doing something useful
}
});
}
});
The sequence of events like this - we click on the element and it changes its layout (expandable). To one of the child elements we bind handler. External handler has a formal parameter position, the value I use the internal handler (but later), because these two events separated in time. I can expand an first ListItem, then expand the second, third,... and then return to the first and click ImageView and cause internal event handler. Question - what value will have a variable position in View.OnClickListener() ? I see - position always have "right" value, why?