【问题标题】:String array of image URL in Android GridViewAndroid GridView中图像URL的字符串数组
【发布时间】:2014-06-06 14:38:50
【问题描述】:

我有一组照片,其中包含从 web 服务获得的 url。 现在我想将照片显示到网格视图中,但我似乎可以理解你是如何做到的..

这是我简化的代码:

public GridView grid1;
public String photos[];


grid1 = (GridView)root.findViewById(R.id.gridphotos);
grid1.setAdapter(new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,photos ));
grid1.setTextFilterEnabled(true);

但它只显示链接文本....

我可以使用 WebView 来填充适配器吗?

谢谢

【问题讨论】:

    标签: android image url gridview webview


    【解决方案1】:

    您需要通过扩展 ArrayAdapter 或 BaseAdapter 来创建自己的适配器。 在此处查看示例.. http://www.learn-android-easily.com/2013/09/android-custom-gridview-example.html

    【讨论】:

    • 但是您的可绘制资源中已经有了图像!我只有从 webservice 获得的数组中的 url..
    • 只有字符串变量保存模型模型类中的图像 url 并使用任何图像加载库加载图像。
    • 我有一个字符串数组,但是我无法填充 gridview... :( 因为在适配器中我不能放 .setImageResource(url) 因为它给出了错误
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 2012-12-13
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多