I'm trying to show a list in Sony Smartwatch 2 in the Control Class. I am doing the same as for a TextView:
// Prepare a bundle to update text. Bundle bundle1 = new Bundle();
bundle1.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text);
bundle1.putString(Control.Intents.EXTRA_TEXT, "Helloooooo");
And this works fine, but I don't know how to do it for ListView, something like this doesn't work:
String[] values = new String[] { "Android", "iPhone",
"WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7",
"Max OS X", "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2",
"Android", "iPhone", "WindowsMobile" };
final ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < values.length; ++i) {
list.add(values[i]);
}
final StableArrayAdapter adapter = new StableArrayAdapter(this,android.R.layout.simple_list_item_1, list);
// Prepare a bundle to update the button text.
Bundle bundle1 = new Bundle();
bundle1.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.list);
bundle1.putStringArray(Control.Intents.EXTRA_DATA, values);
Please help me :S, I think it is something like this:
Bundle b = new Bundle();
b.putInt(Control.Intents.EXTRA_DATA_XML_LAYOUT,
R.layout.smartwatch2_item);
b.putInt(Control.Intents.EXTRA_LIST_ITEM_ID, i);
b.putInt(Control.Intents.EXTRA_LIST_ITEM_POSITION, i);
b.putParcelableArray(Control.Intents.EXTRA_LAYOUT_DATA, views);
Items of SmartWatch's ListView can be sent only by sendListItem(ControlListItem item). Usually, sendListItem is called in onRequestListItem Callback. onRequestListItem is called when sendListCount and sendListPosition is called.
So, you should not send item by adapter, should call sendListCount and sendListPostion.
ControlListItem has dataXmlLayout and layoutData. dataXmlLayout should be item's layout. layoutData should be bundle array.
Please attention to that SmartWatch's layout support is limited.