Get other child that shares parent with the current view
If you know the ID of a child element then you can do the following:
ViewGroup row = (ViewGroup) v.getParent();
TextView textView = (TextView) row.findViewById(R.id.childID);
If you can get a ViewParent
, you can then cast it to a ViewGroup
and get the View
you need. Your code will look like this:
TextView textView = null;
ViewGroup row = (ViewGroup) v.getParent();
for (int itemPos = 0; itemPos < row.getChildCount(); itemPos++) {
View view = row.getChildAt(itemPos);
if (view instanceof TextView) {
textView = (TextView) view; //Found it!
break;
}
}
That's it, assuming you have only one TextView
in your row.