I am trying to build a live card for Glass which displays a list using a ListView
. It's a high-frequency live card in Glass terms. I've tried using a plain ListView
as well as the those from the example here. I've also tried using an ArrayAdapter
and SimpleAdapter
but in each case, none of the data appear when the card is rendered.
What do I need to change to make the list items display?
My live card renderer has a draw()
method called at a regular interval which contains the following:
Canvas canvas;
try {
canvas = mHolder.lockCanvas();
} catch (Exception e) {
return;
}
if (canvas != null) {
string[] from = new String[] {"col1", "col2"};
List<Map<String, String>> fillMaps = new ArrayList<Map<String, String>>();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, R.layout.grid_item, from);
mScroll.setAdapter(adapter);
mLayout.invalidate();
mLayout.draw(canvas);
canvas.save();
mHolder.unlockCanvasAndPost(canvas);
}
My view is a LinearLayout
which contains a ListView:
<ListView
android:id="@+id/orders_list"
android:layout_width="fill_parent"
android:layout_height="350dp"
android:layout_marginLeft="5dp"
android:background="@android:color/holo_blue_light"
android:divider="@null"
android:listSelector="@android:color/transparent" />
and the layout for each row is defined as
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textSize="30sp"/>
</LinearLayout>
I've successfully diplayed a ListView
within an Activity
and then displayed that activity but that's not what I want to do in this situation. I've also tried using the 'low frequency' rendering method of creating live cards (using a RemoteView
) but again, nothing gets displayed. In this example all you get is a blue box (I've coloured the background to the ListView
so I could see which area of the view it was taking up).
My question is: Is there a bug in the Glass rendering framework which is preventing the rows of data being displayed? If not, what is wrong with the above example? Are there any examples of live cards containing lists elsewhere I can reference?
Marking this as answered as it's resolved in a later glass update.