0

내 서버에서 Oval 결과를 얻었으며 Oval.png을 내 그림 파일 폴더로 설정했습니다. 하지만 그것을 설정할 때 런타임 출력은 NoResource Found입니다. 아래의 방법으로 이미지를 ImageView로 설정합니다.ContextCompat.GetDrawable이 android (Xamarin)에서 예상 결과를 제공하지 않음

코드 :

var drawName = item.Shape; 
var resId = ContextCompat.GetDrawable(context,context.Resources.GetIdentifier(drawName, "drawable", context.PackageName)); 

vh.dImage.SetImageDrawable(resId); 

또는 : 나는 또한 다음 이미지를 설정할 수 있습니다 경우 그 작동하지. 나는 소문자해야 RecycleView.Adapter

답변

0

드로어 블 리소스 파일에서 위 코드를 사용하고

var drawName = item.Shape; 
var resId = context.Resources.GetIdentifier(drawName, "drawable", context.PackageName); 

vh.dImage.SetImageResource(resId); 

아래의 코드입니다. 그렇지 않은 경우 GetIdentifier()가 항상 0을 반환하는 등의 다양한 문제가 발생합니다.

관련 문제