Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.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应用程序小部件中将图像视图的资源id转换为图像视图对象。_Android_Imageview_Android Appwidget - Fatal编程技术网

如何在android应用程序小部件中将图像视图的资源id转换为图像视图对象。

如何在android应用程序小部件中将图像视图的资源id转换为图像视图对象。,android,imageview,android-appwidget,Android,Imageview,Android Appwidget,我正在尝试将代码中的url更改为图像视图来显示图像。如何将布局中图像视图的资源id转换为ImageView对象。应用程序小部件中没有findViewById,RemoteView具有setImageViewResource,但它只接受drawables,而不接受布局xml中的id。伙计们,请帮帮我 ImageView logoView = new ImageView(); logoView.setImageResource(R.id.merchant_image);//this is error

我正在尝试将代码中的url更改为图像视图来显示图像。如何将布局中图像视图的资源id转换为ImageView对象。应用程序小部件中没有findViewById,RemoteView具有setImageViewResource,但它只接受drawables,而不接受布局xml中的id。伙计们,请帮帮我

ImageView logoView = new ImageView();
logoView.setImageResource(R.id.merchant_image);//this is error as this id is not in drawable but in layout.

请引导..

更改

ImageView logoView = new ImageView();

编辑

警告“承载多个应用程序的进程的类装入器可能会失败”

试试看


我们无法在应用程序小部件中使用findViewById。此外,我没有使用可绘制图像更新我的资源id,而是通过url更新。是的,您可以通过url更新!首先从url获取图像并将其存储到位图,然后使用:logoView.setImageBitmap(yourBitmapImageObject)@阿提斯卡对不起,我现在明白你的意思了,有点晚了!试试我最新的答案!07-12 12:02:12.708:W/ActivityThread(5316):ClassLoader.getResources:线程返回的类加载器。对于承载多个应用程序的进程,getContextClassLoader()可能会失败。您应该显式指定上下文类加载器。例如:Thread.setContextClassLoader(getClass().getClassLoader());
ImageView logoView = (ImageView)getView()findViewById(R.id.merchant_image);