应该如何使用kotlin将findViewById传递数据从活动页面写入片段页面
How should write the findViewById pass data to Fragment page from Activity page using kotlin
- MIN LEE 问题:
- //这是我的活动页面
- 覆盖乐趣接收检测(检测:检测。检测){
val barcodes = detections.detectedItems if (barcodes.size() == 1) { scannedValue = barcodes.valueAt(0).rawValue runOnUiThread { cameraSource.stop() toastText = scannedValue Toast.makeText(this@InsertStockInActivity, toastText, Toast.LENGTH_SHORT).show() val i = Intent(this@InsertStockInActivity, InputStockInActivity::class.java) i.putExtra("key", toastText) startActivity(i) finish() } }else { Toast.makeText(this@InsertStockInActivity, "value- else", Toast.LENGTH_SHORT).show() } }
- //这是我的片段页面,我使用了()。getIntent(),如何显示“密钥”数据?
- val value=requirectivity()。意图getStringExtra(“密钥”)?:“
绑定。艾迪德。findViewById(R.id.value) - 装订。艾迪德。发现它出错了,我该怎么写这行呢?
- 回答: