Creating a bitmap from png file stored at sdcard (Android)

后端 未结 1 1815
情深已故
情深已故 2021-01-14 17:20

Im trying to create a Bitmap from a Png file stored on the SD card and then set that Bitmap in an imageView. But its not working.

Here\'s the code:

i         


        
相关标签:
1条回答
  • 2021-01-14 18:11

    You can't..

    ImageView BackGround=(ImageView)findViewById(R.id.imageView1);
    BackGround.setImageBitmap(BckGrnd);
    

    How can you get the reference of ImageView in non activity class Getbackground?

    You can only update UI component in MainUI Thread and if its in non Activity class then using reference (Context) of that calling activity class only.

    So put this code in your Activity class after Getbackground completes.

    0 讨论(0)
提交回复
热议问题