如何在Android Studio中保存自定义视图状态
我正在开发具有绘图功能的应用程序。我想用视图将图纸保存在房间数据库中(用户绘制的任何用户)。当用户从历史记录中单击他的图纸时,应恢复它。
if (stateBundleFromDb!=null){
super.onCreate(stateBundleFromDb)
mySavedState = stateBundleFromDb
}else{
super.onCreate(savedInstanceState)
mySavedState = savedInstanceState
}
当我单击一个历史记录项目之一时,我会得到stateBundleFromDB
,但是当我直接打开活动时,我会得到savedinstancestate
。
是否有任何可能的方法可以将视图状态保存在本地存储中?
将不胜感激! 谢谢。
I'm developing an application which has drawing functionality. I want to save my drawing in the room database with the view(whatever users draw). It should be restored when the user clicks on his drawing from their history.
if (stateBundleFromDb!=null){
super.onCreate(stateBundleFromDb)
mySavedState = stateBundleFromDb
}else{
super.onCreate(savedInstanceState)
mySavedState = savedInstanceState
}
When I click one of the history items I get stateBundleFromDb
but when I open the activity directly then I get savedInstanceState
.
Is there any possible way to save view state in local storage?
Any help would be appreciated!
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论