如何在公共 LocationCallback 函数中不断更改 xml 元素? - 安卓

问题描述

我可以访问 speedView(getText 很好),但是 setText 不起作用!没有错误,但是speedView的文字没有变化。

activity_ar_navigation 使用 mapBox 视觉。

 public LocationCallback locationCallback = new LocationCallback() {
    @Override
    public void onLocationResult(LocationResult locationResult) {
        super.onLocationResult(locationResult);


        LayoutInflater inflater1 = LayoutInflater.from(LocationService.this);
        View root = inflater1.inflate(R.layout.activity_ar_navigation,null,true);
        TextView speedView = (TextView)root.findViewById(R.id.speed);
        speedView.setText("this is a test");

        (.....)

    }
};

`

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<com.mapBox.vision.ar.view.gl.VisionArView
    android:id="@+id/mapBox_ar_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<TextView
    android:id="@+id/speed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="20dp"
    android:textSize="30dp"
    android:textColor="@android:color/holo_green_light"
    android:background="@color/white"
    android:text=""/>

</FrameLayout>

有什么想法吗?提前致谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...