索尼Smartwatch折价 - 在同时多TextViews更新文本 [英] Sony Smartwatch - update text in multiple TextViews simultaneously

查看:156
本文介绍了索尼Smartwatch折价 - 在同时多TextViews更新文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在观看同时进行。

main_layout.xml

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <TextView
        android:id="@+id/text1"
        android:layout_width="220px"
        android:layout_height="50px"
        />
    <TextView
        android:id="@+id/text2"
        android:layout_width="220px"
        android:layout_height="50px"
        />
</LinearLayout>

现在我做的是这样的:

sendText(R.id.text1, "Hello world 1");
sendText(R.id.text2, "Hello world 2");

的问题是,我可以在观看看到,第一个文本被先前设置,则第二个。我想避免这种情况。

The problem is, that I can see on the Watch, that the first text is set earlier, then the second one. And I would like to avoid that.

一般情况下,索尼SDK呈现出布局时支持包的数据更新,例如:

Generally, Sony-SDK supports the data-updates in bundles, for example when showing a layout:

Bundle b1 = new Bundle();
b1.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text1);
b1.putString(Control.Intents.EXTRA_TEXT, "Hello world 1");

Bundle b2 = new Bundle();
b2.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text2);
b2.putString(Control.Intents.EXTRA_DATA_URI, "Hello world 2");

Bundle[] layoutData = new Bundle[] { b1, b2 };

showLayout(R.layout.main_layout, layoutData);

但在这种情况下的布局被重新设定,这是不在我的情况那么好,因为在屏幕上的某些其他的观点可能已经改变。

but in this case the layout is re-set, which is not so good in my case, because some other views on the screen may already have been changed.

我希望,它可能是有可能通过类似的东西来实现这一点:

I hoped, it could be possible to achieve this through something like:

Bundle bundle = new Bundle();
bundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text2);
bundle.putString(Control.Intents.EXTRA_TEXT, "Hello world 2");

Intent intent = new Intent(Control.Intents.CONTROL_SEND_TEXT_INTENT);

intent.putExtra(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text1);
intent.putExtra(Control.Intents.EXTRA_TEXT, "Hello world 1");

intent.putExtra(Control.Intents.EXTRA_LAYOUT_DATA, new Bundle[] { bundle });

sendToHostApp(intent);

但遗憾的是关注似乎忽略了CONTROL_SEND_TEXT_INTENT意图EXTRA_LAYOUT_DATA。

but unfortunately the Watch seems to ignore the EXTRA_LAYOUT_DATA for the CONTROL_SEND_TEXT_INTENT intent.

所以我的问题是:是否有可能发送文字更新为包,而无需重新设置布局

So my question is: is there any possibility to send text updates as a bundle without re-setting the layout?

推荐答案

您正在做的是正确的。更新整个屏幕将是最好的方式,只需更新可能在此期间也发生了变化的所有其他领域。

You're doing it right. Updating the whole screen would be the best way, just update all other fields that might have changed in meantime also.

这篇关于索尼Smartwatch折价 - 在同时多TextViews更新文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆