android - 读取 rss 提要时提取图像 url

标签 android

我在阅读 RSS 提要时必须提取图像的 url。有人告诉我使用正则表达式,但我没能建立正确的模式。

最佳答案

你要先

公共(public)类实用程序{

public static Bitmap getBitmapFile(String str)
{
    Bitmap bmImg=null;
    URL myFileUrl;
    try {
        myFileUrl = new URL(str);
        HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
        conn.setDoInput(true);
        conn.connect();
        InputStream is = conn.getInputStream();
        bmImg = BitmapFactory.decodeStream(is);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return bmImg;

}

无论你得到什么样的东西

String str="www.fifa.com/img.jpg"
ImageView img=(Imageview)findviewbyId(R.id.img);

Bitmap bmp=Utility.getBitmapFile(str);
img.setImageBitmap(bmp);

在 ImageView 中看到解析后的图像

关于android - 读取 rss 提要时提取图像 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4657493/

相关文章:

android - 在 Android 上运行 "Hello World!"ANSI C 程序?

java - 按下长点击时防止短点击

android - FusedLocationProviderClient 何时以及如何停止 Looper?

android - 覆盖 flavor 和构建类型之外的应用程序 ID

java - Android Volley 空指针异常

android - 如何在 Activity 中接收 Intent

android - 以编程方式检查 api 版本 ICS 不起作用

Android sdk 管理器不下载包

Android 嵌入式 HTML5 视频

java - Fragment webView无法检测到Google map (您的位置)