简体   繁体   English

根据字段更改更新Android SQLite数据库

[英]Updating an Android SQLite Database on Field Change

I'm writing an android application and on one of my pages, I have a text field, a spinner, and a date picker that need to be saved/updated in a SQLite database. 我正在编写一个android应用程序,并且在我的页面之一上,有一个文本字段,一个微调框和一个日期选择器,需要在SQLite数据库中保存/更新。 All three have default values on creation, and the database needs to update any time a field is changed (there's no 'Save' button or anything like that). 这三个都具有创建时的默认值,并且只要字段更改(没有“保存”按钮或类似的东西),数据库就需要更新。 I've looked into using an onFocusChangeListener() for this, but it seems like the application only changes focus when using text fields, so it wouldn't work with a spinner or datepicker. 我已经考虑过为此使用onFocusChangeListener(),但似乎该应用程序仅在使用文本字段时才更改焦点,因此它不适用于微调器或日期选择器。 I've also tried splitting the components into fragments and overwriting the onPause() method with update functionalities thinking that the fragments paused when the user moved on to the next one but I think that it still only checks when the user leaves the screen. 我还尝试过将组件拆分为片段,并使用更新功能覆盖onPause()方法,并认为片段会在用户移至下一个片段时暂停,但我认为它仍然仅检查用户何时离开屏幕。 Any help/advice would be greatly appreciated. 任何帮助/建议将不胜感激。 Thanks! 谢谢!

对于Spinner ,你可以尝试OnItemSelectedListener ,为Datepicker ,尝试OnDateChangedListener

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM