Android getResources/getIdentifier not returning ID

前端 未结 2 1683
忘掉有多难
忘掉有多难 2021-01-20 05:03

I have code like tthis:

String s = \"replace__menu__\" + data.imageid + \".png\";
int RID = this.getApplicationContext().getResources().getIdentifier(s, \"dr         


        
相关标签:
2条回答
  • 2021-01-20 05:15
    ".png" is not part of a ressource name
    "drawable-hdpi" I would try just 'drawable' instead 
    
    0 讨论(0)
  • 2021-01-20 05:16

    Try this

    String s = "replace__menu__" + data.imageid;  // image name is needed without extention
    int RID = this.getApplicationContext().getResources().getIdentifier(s, "drawable", getPackageName());
    
    0 讨论(0)
提交回复
热议问题