这里我们通过C#的反射机制来实现这个功能,以获取Resource/drawable文件夹下的图片为例: public int getResourceByReflect(String imageName) { var drawable = typeof(Resource.Drawable); int r_id = 0; try { var field = drawable.GetField(imageName); r_id = (int)field.GetValue(field.Name); } catch (Exception e) { } return r_id; } 使用方法: var id = getResourceByReflect(iconItem.Name); if (id == 0) return; var picture = BitmapFactory.DecodeResource(Context.Resources, id); 需要指出的是,在原生技术中,也可以通过反射实现这个功能,但其反射的目标对象是J……
Android: // <AppHome>/files string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); iOS: // <AppHome>/Documents string docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // to meet Apple’s iCloud terms, content that is not generated by the user // should be placed in the /Library folder or a subdirectory inside it string libFolder = System.IO.Path.Combine(docFolder,"..", "Library"); WindowPhone: // <AppHome>\local string path = Windows.Storage.ApplicationData.Current.LocalFolder.Path;……