我正在开发 Android 应用程序。它有大约40个屏幕。我有条形码扫描仪,大约 20 个屏幕上应该有它。我需要使用 TextInput 将值从条形码扫描仪屏幕传递到其他屏幕。目前,我添加到一个屏幕:
labScreen = "page3"
self.manager.get_screen(labScreen).ids.labBarcode.text = self.barcodeData
self.manager.current = labScreen
此代码有效,但需要为每个页面创建新的条形码扫描仪屏幕+设计,这是不好的做法(概念),因为我需要重复自己。我想使用 OOP(面向对象编程),例如调用/使用一次并从不同屏幕将数据获取到 TextInput 字段。怎么做?谢谢。
最佳答案
好的。我已经通过使用修复了它:
MDApp.get_running_app().barcodeValue = self.barcodeData
self.manager.current = MDApp.get_running_app().previousScreen
并将上一屏幕设置为:
MDApp.get_running_app().previousScreen = self.manager.current
现在效果很好。问题已解决。
关于python - 将值从屏幕管理器屏幕问题传递到字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60230136/