Is there a way to get the resource identifier (e.g. R.layout.viewtoInflate) of the layout from which the view was inflated?
I am trying to implement a list view that uses 2 custom layouts for list items. Which layout of the element is used based on the field in the objects used to populate the list.
What I am missing in my user adapter is a way to find out from which resource the envelope I get in getView () was received. If I could get this information, I could compare and determine if I can reuse the conversion view as it is, or if I have to replace it with the appropriate layout for the current element.
Ideally, it would be something like this:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
JSONObject currItem = mItems.getJSONObject(position);
int layoutType;
if (currItem.getBoolean("alternate"))
layoutType = R.layout.list_item_b;
else
layoutType = R.layout.list_item_a;
if (convertView == null || <convertView.resourceID> != layoutType ) {
convertView = inflater.inflate(layoutType, null);
}
else {
}
return convertView;
}
, , .