如何将不同的文本添加到每个可渲染视图的TextView

时间:2019-05-07 14:17:55

标签: android sceneform

我正在尝试创建带有文本视图的可渲染视图。我正在创建同一RendrableView的多个副本。当我尝试在任何可渲染视图中更改文本时,更改将反映在所有视图中。在这种情况下,有人可以帮助我吗?

视图的代码段:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/txts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:padding="4dp">

 <TextView
    android:id="@+id/dimentionsTxt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="TextView" />

</LinearLayout>

而android代码是:

private void createTxtNode(Node parent, String value)
{
    Node dimentionNode = new Node();
    dimentionNode.setParent(parent);

    dimentionNode.setRenderable(dimentionsRenderableView.makeCopy());
    dimentionNode.setLocalPosition(Vector3.zero());
    dimentionNode.setLookDirection(c.getForward());
    dimentionNode.setLocalScale(new Vector3(0.1f,0.1f,0.1f));
    ViewRenderable r = (ViewRenderable)dimentionNode.getRenderable();
    View v = r.getView();
    TextView dimention = v.findViewById(R.id.dimentionsTxt);

        dimention.setText(value);
}

实际输出:
如果我有2个可渲染视图,
当我添加第一个视图14条地铁时。

第二个可渲染视图:
12吨,12米。意味着14兆被12兆代替。

预期输出为:
14mtrs,12米。

0 个答案:

没有答案