Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 android 应用程序中有一个 ImageView,我的桌面上有一张图片。我想将此 imageView 与桌面图像的路径相关联,以便在我运行我的应用程序时显示图像。有人可以帮我写代码吗?谢谢 !
您无法打开不在运行应用程序的设备上的文件。
将您的图片移动到/res/drawable应用程序的目录中或目录中,然后您将能够在ImageView.
/res/drawable
ImageView
如果您的图像被调用picture1.png并且它位于应用程序的目录/res/drawable中,您可以ImageView像这样设置查看它:
picture1.png
imageView.setBackgroundResource(R.drawable.picture1);