Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 从drawable文件夹在Recycler视图的ImageView中显示多个图像_Android_Android Recyclerview_Imageview - Fatal编程技术网

Android 从drawable文件夹在Recycler视图的ImageView中显示多个图像

Android 从drawable文件夹在Recycler视图的ImageView中显示多个图像,android,android-recyclerview,imageview,Android,Android Recyclerview,Imageview,我正在从存储在内部存储器中的excel文件读取员工数据,不幸的是,该应用程序完全脱机,因此有脱机图像,我需要将其存储在drawable文件夹中 现在我的问题是; 例如,有350个名为employee id的图像 emp id的1.jpg=1,emp id的2.jpg=2 我使用的是RecyclerView,在onBindViewHolder方法中,我必须根据员工id设置图像 请引导我将图像显示到imageView中。 请评论我方的更多意见 如果你不能回答,请不要标为否定 你可以试试这样的东西 例

我正在从存储在内部存储器中的excel文件读取员工数据,不幸的是,该应用程序完全脱机,因此有脱机图像,我需要将其存储在drawable文件夹中

现在我的问题是; 例如,有350个名为employee id的图像 emp id的1.jpg=1,emp id的2.jpg=2

我使用的是RecyclerView,在onBindViewHolder方法中,我必须根据员工id设置图像

请引导我将图像显示到imageView中。 请评论我方的更多意见


如果你不能回答,请不要标为否定

你可以试试这样的东西

例如,如果试图获得雇员1526,可提取的将是R.drawable.1526

String id = employee.getId(); //1526
int imageId = context.getResources()
                     .getIdentifier(id, "drawable", context.getPackageName());
id是一个字符串。 然后是图像视图

imageView.setImageResource(imageId);