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:

  1. 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?
  2. 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

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -