Android Utililty Methods View Position Get

List of utility methods to do View Position Get

Description

The list of methods to do View Position Get are organized into topic(s).

Method

intgetPositionForView(final AdapterView adapterView, final View view)
Get the position within the adapter's dataset for the view, where view is an adapter item or a descendant of an adapter item.
int position = adapterView.getPositionForView(view);
if (adapterView instanceof ListView) {
    position -= ((ListView) adapterView).getHeaderViewsCount();
return position;
intgetRelativeTop(View myView)
get Relative Top
return getTop(myView) - myView.getTop();
intgetTop(View myView)
get Top
if (myView.getParent() == myView.getRootView())
    return myView.getTop();
else
    return myView.getTop() + getTop((View) myView.getParent());