-1

私は別のプロジェクトからコピーしていたコードを持っています。これにより、URLを渡すことができ、画像が返されます...次に、画像ビューに設定すると画像が表示されます...しかし、どこかで...取得した画像が表示されなくなりました...このコードを見て、何か問題があるかどうか教えてもらえますか?

クリックイベント

void NextPic(View v)
{
    picNum++; //int holding what pic number we are on
    Drawable bPic = LoadImageFromWebOperations(picData[]); //picData = String[] with url data in it
    imgView.setImageDrawable(bPic); //Cast earlier in the code
}

Get Pic 関数

private Drawable LoadImageFromWebOperations(String url)
{
    try
    {
        InputStream is = (InputStream) new URL(url).getContent();
        Drawable d = Drawable.createFromStream(is, "src name");
        return d;
    }
    catch(Exception e)
    {
        //Custom error handler
        uu.SendError(e.getMessage(), "Main.GetPickTask.LoadImageFromWeboperations(String url)");
        return null;
    }
}

LogCat には何も表示されません...エラーは発生しません...そして、写真は空白のままです... ic_launcher グラフィックをプレースホルダーとして使用したので、それがイメージビュー自体であるかどうかを確認してください...しかし、それが表示されます数秒後に黒くなります

これは、私が使用している URL の例です http://app.guycothal.com/Funnys/2012722133515231.jpg

4

1 に答える 1

0
    private Drawable ImageOperations(Context ctx, String url, String saveFilename) {
        try {
            InputStream is = (InputStream) fetch(url);
            Drawable d = Drawable.createFromStream(is, "src");
            return d;
        } catch (MalformedURLException e) {
            return null;
        } catch (IOException e) {
            return null;
        }
    }
    public Object fetch(String address) throws MalformedURLException,IOException {
        URL url = new URL(address);
        Object content = url.getContent();
        return content;
    }
于 2012-07-25T04:55:15.093 に答える