2015-11-09 29 views
0

getDrawable被取消。我怎样才能重写这段代码。我无法找到答案。如何替换getDrawable

public static List<Product> getCatalog(Resources res){ 
    if(catalog == null) { 
     catalog = new Vector<Product>(); 
     catalog.add(new Product("Dead or Alive",src.getDrawable(R.drawable.deadoralive), 
       "Dead or Alive by Tom Clancy with Grant Blackwood", 29.99)); 
     catalog.add(new Product("Switch", res 
       .getDrawable(R.drawable.switchbook), 
       "Switch by Chip Heath and Dan Heath", 24.99)); 
     catalog.add(new Product("Watchmen", res 
       .getDrawable(R.drawable.watchmen), 
       "Watchmen by Alan Moore and Dave Gibbons", 14.99)); 
    } 

    return catalog; 
} 

什么是使用它的新功能最好的方法。

+1

它是一种重复的问题 –

+0

我知道有很多问题已经被问及geDrawable在这个网站,但我是新Android开发,所以我需要确切的答案,因为我无法做到这一点。 – vikky

回答

1

。例如。

Drawable drawable = ContextCompat(context, R.drawable.deadoralive);