0

I am new to android.

I created an Image View to display an image from the file browser and this is working correctly.

The problem is once i come out of my application and open it again. The image I selected isn't there in the image view.

That means only at the time I am using my application, the image is present inside the imageview. The next time I open it, the image is vanished and I have to select the image from the file browser again.

So how can I store the image permanently inside the imageview until I change that image?

4

1 回答 1

0

您不能持久地将图像“存储在 ImageView 中”,因为 ImageView 不是持久对象。每次您的活动调用 setLayout() 失去它可能拥有的所有状态时,它都会重新创建(或者,准确地说,它并没有完全失去它的状态,因为它被一个全新的空白 ImageView 取代)。

相反,您需要将图像存储到持久存储中(例如,如果您从 Internet 加载它)并在 onCreate() 中重新加载它。

于 2014-02-04T13:32:52.503 回答