title: Get resource id from which view was inflated
body: <p>Is there a way to obtain the resources id (like R.layout.viewtoInflate) of the layout from which a view was inflated?</p>
  
  <p>I am trying to implement a List View that uses 2 custom layouts for the list items. Which item layout is used is based on a field in the objects used to populate the list view.</p>
  
  <p>What I am missing in my custom adapter is a way to know what resource the 'convertView' I get in the getView() was inflated from. If I could get that info I can compare and determine whether I can re-use the convert view as it is or if I have to replace it with the appropriate  layout for the current item.</p>
  
  <p>So ideally it would be something like this:</p>
  
  <pre><code>@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 || &lt;convertView.resourceID&gt; != layoutType ) {
          convertView = inflater.inflate(layoutType, null);
  
          //Finish setting up new View and its holder
      }
      else {
          //Get view holder for view reuse
      }
  
      //populate view with the required content
  
      return convertView;
  }
  </code></pre>
  
  <p>At worst I could just not re-use views at all and just inflate the layout I need every time, but it seems very wasteful. </p>