【问题标题】:How can I change the value of the variable continuously in the class(which I create)如何在类(我创建的)中不断更改变量的值
【发布时间】:2019-12-10 08:41:15
【问题描述】:

我是 Android 初学者。

我正在尝试制作一个执行某些工程过滤器的应用程序。

MainActivity 中有一个 Thread,我创建了一些类来简化我的代码。
MyApp

我在headingFilter类中声明了很多变量,我想不断地改变它的值。 headingFilter

我的问题是我该怎么做。

我认为像图片3那样有可能,但这是不可能的。 picture3

我尝试像图片4一样,但我在 headingFilter 类中声明的值根本没有改变。 picture4

我认为该值不会改变,因为线程执行 headingFilter hFilter = new headingFilter(); 连续。

请帮帮我~~~

【问题讨论】:

    标签: android multithreading class variables


    【解决方案1】:

    将 headingFilter 类设为静态以访问它。

    改变

    public class headingFilter {

    public static class headingFilter {

    【讨论】:

    • 感谢您的评论,但仍然无法正常工作。
    • 您能添加更多文本格式的代码吗?需要查看更多headingFilter 类和调用headingFilter.cal_heading() 的类
    猜你喜欢
    • 2014-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多