2014-11-14 4 views
1

제어 클래스의 Sony Smartwatch 2에 목록을 표시하려고합니다. TextView의 경우와 같습니다.Sony Smartwatch 2의 목록보기

// 텍스트를 업데이트하기 위해 번들 준비. 번들 번들 1 = 새 번들();

bundle1.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.text); 
    bundle1.putString(Control.Intents.EXTRA_TEXT, "Helloooooo"); 

그리고 이것은 잘 작동하지만 내가 ListView를 위해 그것을 할 방법을 모른다, 이런 식으로 뭔가가 작동하지 않습니다

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); 

나를 도와주세요 : S를, 나는 생각

 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); 

답변

1

항목이 sendListItem (ControlListItem 항목) 만 보낼 수 아래의 코드를 추가합니다. 일반적으로 sendListItem은 onRequestListItem 콜백에서 호출됩니다. onRequestListItem은 sendListCount 및 sendListPosition이 호출 될 때 호출됩니다.

따라서 어댑터별로 항목을 보내지 말고 sendListCount 및 sendListPostion을 호출해야합니다.

ControlListItem에는 dataXmlLayout 및 layoutData가 있습니다. dataXmlLayout은 항목의 레이아웃이어야합니다. layoutData는 번들 배열이어야합니다.

public void onResume(int layoutReference, int listItemPosition) { 
    showLayout(YOUR_LAYOUT_HAS_LIST_VIEW); 
    sendListCount(values.length); 
    sendListPosition(YOUR_LIST_VIEW, 0); 
} 
public void onRequestListItem(int layoutReference, int listItemPosition) { 
    ControlListItem item = new ControlListItem(); 
    item.layoutReference = layoutReference; 
    item.dataXmlLayout = android.R.layout.simple_list_item_1; 
    item.listItemId = listItemPosition; 
    item.listItemPosition = listItemPosition; 
    item.layoutData = new Bundle[1]; 
    item.layoutData[0] = new Bundle(); 
    item.layoutData[0].putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, android.R.id.text1); 
    item.layoutData[0].putString(Control.Intents.EXTRA_TEXT, values[listItemPosition]); 
    sendListItem(item); 
} 

SmartWatch의 레이아웃 지원에는 제한이 있습니다.

+0

감사합니다! 이것이 해결책입니다. – xarrate

0

어댑터를 만들었지 만 어댑터를 목록보기에 추가하지 않았습니다.

주요 활동 코드가 불완전하기 때문에 정확한 문제를 정확히 지적 할 수 없습니다.

는 레이아웃에서 목록보기에 액세스 SmartWatch의의의 ListView의

ListView lv = (ListView) this.findViewById(R.id.yourlistviewIDname)); 

ArrayAdapter<String> adapter = new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, your_list); 

lv.setAdapter(adapter); 
+0

친애하는 @VikramEzhil Smartwatch에서이 작업을 수행하려고하는데 Smartwatch에서 어댑터 코드가 작동하지 않습니다. EXTRA_LIST_ITEM_ID로 뭔가를해야한다고 생각합니다. – xarrate

+0

죄송합니다. 솔직히 말해서 똑똑한 시계와는 다른 것을 알지 못했습니다. 올바른 해결책은 나에게 좋은 학습 곡선이었습니다. –

관련 문제