How to know if a view was inflated from an resource file (xml) in Android? -
i have method:
@override public itemviewholder oncreateviewholder(viewgroup parent, int viewtype) { layoutinflater inflater = layoutinflater.from(context); view inflated = inflater.inflate(r.layout.item_lunch_view, parent, false); return new itemviewholder(inflated); } is there way this?
itemviewholder holder = oncreateviewholder(); if(holder.itemview.inflatedfrom(r.layout.item_lunch_view)){ log.i("stackoverflow", "yes, view builded r.layout.item_lunch_view"); }
not really. should rethink problem. here solutions come mind:
- set tag of view holder id of parent view plus unique id suffix can still distinguish between multiple items. since tag can why not that?
if have multiple parent xmls, define different id format child views in each one, looking @ id of child can tell 1 parent. example
parent
child android:id="+@id/parent1_view1"
child android:id="+@id/parent1_view2"
/parent
parent
child android:id="+@id/parent2_view1"
child android:id="+@id/parent2_view2"
/parent
Comments
Post a Comment