Android 将位图设置为ImageView时出错

Android 将位图设置为ImageView时出错,android,bitmap,Android,Bitmap,我在android上有一个应用程序,我从facebook页面返回一些图片。我将这些图片作为InputStream返回,然后使用BitmapFactory对它们进行解码,类似这样: BitmapFactory.decodeStream(content); 之后,我尝试将此位图设置为ImageView,但强制关闭。我就是这样做的: public Bitmap doInBackground(String...arg0) { URL profilePicUrl

我在android上有一个应用程序,我从facebook页面返回一些图片。我将这些图片作为
InputStream
返回,然后使用
BitmapFactory
对它们进行解码,类似这样:

BitmapFactory.decodeStream(content);
之后,我尝试将此位图设置为
ImageView
,但强制关闭。我就是这样做的:

 public Bitmap doInBackground(String...arg0)
        {
            URL profilePicUrl=null;
            int nr=0;
            Bitmap profilePicBitmap=null;
    final String imageURL="http://graph.facebook.com/"+arg0[0]+"/picture?type=small";
                 try{

profilePicBitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
            System.out.println("Returnam poza numarul:"+profilePicBitmap);

            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return profilePicBitmap;
                    }

public void onPostExecute(Bitmap result){
        ImageView imageView_1=null;
        Log.d("We are:","Loaded the pictures");
        imageView_1.setImageBitmap(result);

    }
我使用
AsyncTask
线程从URL返回图片。但我在这一行中得到错误:

imageView_1.setImageBitmap(result);
当我尝试在此处显示解码
InputStream
返回的结果时:

profilePicBitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
                System.out.println("Returnam poza numarul:"+profilePicBitmap);
这就是我得到的:

android.graphics.Bitmap@44e38ee0
android.graphics.Bitmap@44e22010
android.graphics.Bitmap@44dfbe68
android.graphics.Bitmap@44de26f8
android.graphics.Bitmap@44daa718
android.graphics.Bitmap@44dc30a0
android.graphics.Bitmap@44daa080
android.graphics.Bitmap@44de1680
android.graphics.Bitmap@44df7140
android.graphics.Bitmap@44dae9d8
android.graphics.Bitmap@44e5b008
android.graphics.Bitmap@44e0ee20
这就是我的logcat的样子:

java.lang.NullPointerException
at com.SplashScreen.InviteFriends$Task.onPostExecute(InviteFriends.java:214)
at com.SplashScreen.InviteFriends$Task.onPostExecute(InviteFriends.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:417)
at android.os.AsyncTask.access$300(AsyncTask.java:127)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)

请帮帮我,因为我不知道怎么了

onPostExecute
更改中

ImageView imageView_1=null;


onPostExecute
change中

ImageView imageView_1=null;


StackOverflow中有很多关于如何从url下载图像的问题


看到这一点,您可以从这个问题的答案中得到您的解决方案。

StackOverflow中有许多关于如何从url下载图像的问题


看到这一点,你可以从这个问题的答案中得到你的答案

ImageView ImageView_1=null;Log.d(“我们:”,“加载了图片”);imageView_1.设置图像位图(结果);这是什么意思???您正在将imageView设置为null,然后尝试调用它?难怪您会得到一个NullPointerImageView图像视图_1=null;Log.d(“我们:”,“加载了图片”);imageView_1.设置图像位图(结果);这是什么意思???您正在将imageView设置为null,然后尝试调用它?难怪你会得到一个空指针OK…我自己得到的…只是有时候我太迟钝了@阿德里安,你好!就名义而言,在西班牙,我们可以解决一个问题,而不是解决一个问题,因为我们可以解决这个问题。没有考虑的阿尔古纳合唱团,好吧…我自己弄到的…只是有时候我很迟钝@阿德里安,你好!就名义而言,在西班牙,我们可以解决一个问题,而不是解决一个问题,因为我们可以解决这个问题。阿尔古纳合唱团没有考虑过,