Question

I have used the gallery demo for the Sony SmartWatch 2. I create multiple listitems with no error. Now my question, I want to click on the listItem an set a textview with new text.

I create multiple 3 item with:

ControlListItem item = new ControlListItem();
item.layoutReference = R.id.gallery;
item.dataXmlLayout = R.layout.item_gallery;
item.listItemId = position;
item.listItemPosition = position;


// Label data
Bundle labelBundle = new Bundle();
labelBundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.title);
labelBundle.putString(Control.Intents.EXTRA_TEXT, mGalleryContent.get(position).getName());


// Body data
Bundle bodyBundle = new Bundle();
bodyBundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.body);
String url = "test";
bodyBundle.putString(Control.Intents.EXTRA_TEXT, url);

// Image data
Bundle imageBundle = new Bundle();
imageBundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.imageView1);
imageBundle.putString(Control.Intents.EXTRA_DATA_URI, mGalleryContent.get(position).getSymbol());
item.layoutData = new Bundle[3];
item.layoutData[0] = labelBundle;
item.layoutData[1] = imageBundle;
item.layoutData[2] = bodyBundle;

return item;

Now I clicked on the 2 second listItem in the gallery and then I want to set the body the a new string. I have tested with something like this:

public void onListItemClick(final ControlListItem listItem, final int clickType, final int itemLayoutReference) {
Intent intent = new Intent(Control.Intents.CONTROL_SEND_TEXT_INTENT);
intent.putExtra(Control.Intents.EXTRA_LAYOUT_REFERENCE, listItem.layoutReference);
intent.putExtra(Control.Intents.EXTRA_TEXT, "bla bla");
sendToHostApp(intent);

There is no error and no effect. Textview is not changed. I have tried with sendText(R.id.body, "Hello"), too. The same no effect. I think I need the correct LayoutID. But my textview is in the generated listItem. Hmm. Can anyone help me?

Était-ce utile?

La solution

Unfortunately, the API only allows you to update an entire list item. It is not possible to update individual views in a list item.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top