title: getDrawable(int) is deprecated warning in this line: Drawable res = getContext().getResources().getDrawable(item.img_resId);
body: <p>I have created my own custom adapter. In this code I get getDrawable(int) is deprecated warning in this line: <code>Drawable res = getContext().getResources().getDrawable(item.img_resId);</code>.</p>
  
  <p><strong>I go through these:</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/29041027/android-getresources-getdrawable-deprecated-api-22/29041466">Android getResources().getDrawable() deprecated API 22
  </a></p>
  
  <p><a href="https://stackoverflow.com/questions/27796246/android-alternative-for-context-getdrawable">Android: Alternative for context.getDrawable()
  </a></p>
  
  <p>But none of them has work in my case.</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>public class CustomAdapter extends ArrayAdapter&lt;ItemDataObject&gt; {
  private static class ViewHolder {
      ImageView img;
      TextView title;
      TextView sub_title;
  }
  
  public CustomAdapter(Context context, ArrayList&lt;ItemDataObject&gt; list_item_details) {
      super(context, 0, list_item_details);
  }
  
  @NonNull
  @Override
  public View getView(int position, View convertView, @NonNull ViewGroup parent) {
      // Get the data item for this position
      ItemDataObject item = getItem(position);
      // Check if an existing view is being reused, otherwise inflate the view
      ViewHolder viewHolder; // view lookup cache stored in tag
      if (convertView == null) {
          // If there's no view to re-use, inflate a brand new view for row
          viewHolder = new ViewHolder();
          LayoutInflater inflater = LayoutInflater.from(getContext());
          convertView = inflater.inflate(R.layout.listview_item, parent, false);
          viewHolder.img = convertView.findViewById(R.id.img);
          viewHolder.title = convertView.findViewById(R.id.tvTitle);
          viewHolder.sub_title = convertView.findViewById(R.id.tvSubTitle);
          // Cache the viewHolder object inside the fresh view
          convertView.setTag(viewHolder);
      } else {
          // View is being recycled, retrieve the viewHolder object from tag
          viewHolder = (ViewHolder) convertView.getTag();
      }
      // Populate the data from the data object via the viewHolder object into the template view.
      assert item != null;
      Drawable res = getContext().getResources().getDrawable(item.img_resId);
      viewHolder.img.setImageDrawable(res);
      viewHolder.title.setText(item.title);
      viewHolder.sub_title.setText(item.subtitle);
      // Return the completed view to render on screen
      return convertView;
      }
  }
  </code></pre>