ListView行不显示在Glass实时卡中

时间:2014-06-26 16:31:06

标签: android listview android-listview aero-glass

我正在尝试为Glass构建一张活卡,该卡使用ListView显示列表。这是玻璃术语中的高频现场卡。我尝试使用普通ListView以及示例here中的那些。我还尝试使用ArrayAdapterSimpleAdapter,但在每种情况下,在呈现卡片时都不会显示任何数据。

我需要更改什么才能显示列表项?

我的实时卡片渲染器定期调用draw()方法,其中包含以下内容:

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

我的观点是LinearLayout,其中包含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" />

并且每行的布局定义为

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

我已成功在ListView中显示Activity,然后显示该活动,但这不是我想要在这种情况下做的事情。我也尝试使用'低频'渲染方法来创建实时卡(使用RemoteView),但同样没有显示任何内容。在这个例子中,你得到的只是一个蓝色的盒子(我已经将背景着色为ListView,所以我可以看到它占据的视图区域。)

我的问题是:Glass渲染框架中是否存在阻止显示数据行的错误?如果没有,上面的例子有什么问题?是否有任何包含我可以参考的其他名单的活卡的例子?

1 个答案:

答案 0 :(得分:0)

将此标记为已回答,并在稍后的更新中解决。