0

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?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
christof
  • 3
  • 2
  • where is the actual code of "textView.setText()"? is this a listview? assuming it is from the method onListItemClick where is its adapter? – Lena Bru Jan 15 '14 at 20:10
  • in onListItemClick where you put the text to textview ? – mohammed momn Jan 15 '14 at 20:10
  • Yes it is in onListItemClick. There is a generated listItem and in the listItem is a textview the name is body. – christof Jan 15 '14 at 20:34
  • there is no code of textView.setText. I generated the 3 listitems with createControlListItem in the onRequestListItem(final int layoutReference, final int listItemPosition). – christof Jan 15 '14 at 20:37

1 Answers1

0

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

mldeveloper
  • 2,253
  • 1
  • 13
  • 14
  • Ok. I generate 3 listItems on the onResume event. Can I only change only one list item or must I recreate the 3 listitems on every onresume call? – christof Jan 17 '14 at 15:19