Компоновка Sony SmartEyeglass с перекрытием

Я пытаюсь реализовать изменение текста карты на Sony SmartEyeglass, но у меня возникают проблемы с макетами. Я взял расширенный образец макета из SDK и изменил его.

У меня есть макет xml по умолчанию, который отображает заголовок и основной текст. Я поместил «Заголовок» и «Тело» в качестве строк по умолчанию в файле xml и попытался обновить заголовок и тело как «Обновлено» и «Обновлено основной текст». Однако результат показывает мне макет по умолчанию (с «Заголовок» и «Тело») и текст «Обновленный основной текст», перекрывающийся поверх них.

Почему заголовок не редактируется и почему основной текст находится поверх xml TextView?

Вот соответствующий код:

@Override
public void onResume() {
    showingDetail = false;

    ControlListItem item = createControlListItem(namePosition);
    showLayout(item.dataXmlLayout, null);
    sendListCount(item.layoutReference, quotedPeople.size());
    sendListPosition(item.layoutReference, namePosition);
    //utils.sendTextViewLayoutId(R.id.names_body);
    sendListItem(item);
}

private ControlListItem createControlListItem(final int position) {
    Log.d(Constants.LOG_TAG, "position = " + position);

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

    List<Bundle> list = new ArrayList<Bundle>();

    // Header data
    Bundle headerBundle = new Bundle();
    headerBundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.names_title);
    headerBundle.putString(Control.Intents.EXTRA_TEXT, "Updated");
    list.add(headerBundle);

    // Body data
    Bundle bodyBundle = new Bundle();
    bodyBundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.names_body);
    bodyBundle.putString(Control.Intents.EXTRA_TEXT, "Updated body title");
    list.add(bodyBundle);

    item.layoutData = list.toArray(new Bundle[list.size()]);
    return item;
}

Вот файл макета xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="@dimen/smarteyeglass_control_width"
    android:layout_height="@dimen/smarteyeglass_control_height"
    tools:ignore="PxUsage,UselessParent,HardcodedText" >

    <TextView
        android:id="@+id/names_title"
        android:layout_width="400px"
        android:layout_height="30px"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginTop="5px"
        android:paddingLeft="6px"
        android:background="@android:color/black"
        android:text="Title"
        android:textColor="@android:color/white"
        android:textSize="@dimen/smarteyeglass_text_size_normal" />

    <View
        android:id="@+id/names_divider"
        android:layout_width="400px"
        android:layout_height="2px"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/names_title"
        android:background="@android:color/white" />

    <TextView
        android:id="@+id/names_body"
        android:layout_width="400px"
        android:layout_height="78px"
        android:layout_marginTop="5px"
        android:layout_marginLeft="10px"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/names_divider"
        android:textColor="@android:color/white"
        android:textSize="@dimen/smarteyeglass_text_size_small"
        android:text="Body" />

    <Gallery
        android:id="@+id/names_gallery"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </Gallery>

</RelativeLayout>

person Jane Kang    schedule 08.12.2014    source источник


Ответы (1)


мы только что проверили ваш пример, и текст меняется нормально. Похоже, вы выбрали неправильный XML для элемента галереи. Вы начали с smarteyeglass_layout_test_gallery вместо использования smarteyeglass_item_gallery.

person peter.bartos    schedule 09.12.2014
comment
Каковы различия и способы использования файлов item_gallery.xml, smarteyeglass_item_gallery.xml и smarteyeglass_layout_test_gallery.xml? А для чего вообще нужна функция showLayout? - person Jane Kang; 09.12.2014
comment
Запустите пример проекта, чтобы увидеть различные используемые макеты — основную галерею, элемент галереи и подробный макет, который открывается после выбора элемента галереи. showLayout предназначен для отображения макета XML на экране SmartEyeglass. Проверьте справку по API, чтобы увидеть больше деталей. - person peter.bartos; 10.12.2014