如何在运行时放置活动的背景图片?
在我的应用程序中,我让用户选择背景图像(使用 Gallery 从图像库中选择),即单击按钮时,比方说“主题”,将显示 3-4 张图像,用户可以选择其中一张图像。
现在,一旦他这样做,图像就应该出现在活动的背景中。我试图将用户的这个选择保存在我的数据库中。
但我真的不知道如何继续,也就是说,当选择“主题”按钮时,“主题挑选”活动启动,并出现 3-4 个图像的图库...当用户选择图像时,此主题挑选活动“完成”,我们返回到初始活动..现在在这个活动中,我让用户输入一些数据(通过文本字段)。用户单击“保存”后,数据将进入数据库,并且可以很好地检索。但我也想将所选图像的路径(从主题选择活动)保存到数据库,当我检索所有数据并显示数据时(可以说,在单独的活动中),图像应该进入背景也是如此。
我试图尽可能详细地阐述。 我迫切需要一个解决方案,因为我的提交将在 2 天内到期。 谢谢你!
In my app, I am letting the user to select a background image(from a gallery of images using Gallery), i.e., on clicking a button, lets say, 'theme', 3-4 images are shown, and the user gets to select one of the images.
Now as soon as he does that, the image should appear at the background of the activity..I am trying to save this choice, by the user, in my database..
but I really have no idea how to proceed, that is, when the 'theme' button is selected, a 'themepick' activity starts, and a gallery of 3-4 images appear...when the user selects an image, this themepick activity is 'finished' and we go back to the initial activity..now in this activity, I am letting the user enter some data(through text fields) . After the user clicks save, the data is going into the database, and is being retrieved well. But i also want to save the path to the selected image(from the themepick activity), to the database, and when I am retrieving all the data and displaying the data(in a separate activity, lets say), the image should come in the background as well.
I tried to elaborate as much as possible.
I urgently need a solution as my submission is due in 2 days.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 SharedPreference。
Use a SharedPreference.
你的问题似乎并没有具体说明你的问题。如果我理解正确,您尝试在运行时设置布局的背景。
您需要找到布局 ID 并设置背景,如下所示
让我知道它是否对您有帮助..:)
You question doesn't seems to be specific on your problem . If I understood correctly your trying to set a background of an layout on runtime.
You need to find the layout Id and set background as below
Let me know if it helps u.. :)