[英]Accessing the value outside of method after initializing returning nulll in java
unfortunately, there's not all text visible on your screenshot.不幸的是,您的屏幕截图上并未显示所有文本。 On Stackoverflow, it's generally preferred if you paste the source code directly into your question rather than sharing a screenshot.
在 Stackoverflow 上,如果您将源代码直接粘贴到您的问题中而不是共享屏幕截图,则通常是首选。 It's a bit more effort, at the same time, please consider that the people answering your question also take effort to help you - and by posting the source code as text, you make it easier for everyone to help you.
这需要更多的努力,同时,请考虑到回答您问题的人也在努力帮助您 - 并且通过将源代码作为文本发布,您可以更轻松地为每个人提供帮助。
For your question, there's a couple of things that might happen:对于您的问题,可能会发生以下几种情况:
channel=value
and channel+="1"
might happen at the same time, which could give you unpredictable results.channel=value
和channel+="1"
也可能同时发生,这可能会给您带来不可预测的结果。 To solv the problem, you will need to trigger whatever action should happen after your callback at a time when you know that the callback has been called.要解决此问题,您需要在知道回调已被调用时触发回调后应发生的任何操作。 I am no expert on Android;
我不是 Android 专家; there might be listeners available for that.
可能有听众可用。 If not, then the simplest way would be to call the code that should happen after the callback was called from the callback itself (be aware, that this is most likely a bad practise in android as it might make the UI become unresponsive. To solve that, you will need to execute your code on a different thread than the UI thread)
如果没有,那么最简单的方法是在从回调本身调用回调之后调用应该发生的代码(请注意,这很可能是 android 中的一种不好的做法,因为它可能会使 UI 变得无响应。要解决也就是说,您需要在与 UI 线程不同的线程上执行代码)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.