【问题标题】:Custom widget ListView not working properly自定义小部件 ListView 无法正常工作
【发布时间】:2013-12-23 10:34:33
【问题描述】:

我有一个带有 ListView 的小部件,它具有自定义列表项,使用 RemoteViewsService.RemoteViewsFactory 实现。我的布局代码是这样的:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical">

    <View
        android:layout_width="10dp"
        android:layout_height="match_parent"
        android:background="#dabcee" />
    <TextView
        android:id="@+id/widgetRow"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:textColor="#333"
        android:textSize="20sp"
        android:drawableRight="@drawable/ic_action_next_item"/>    
</LinearLayout>

此布局的问题在于它不起作用,它会为每个列表项显示“正在加载...”。问题是,如果我删除第一个 View,它只是作为一个设计元素,并在每个项目的开头添加一个彩色条......它可以工作。我怎样才能使它与第一个 View 一起工作?

谢谢!

【问题讨论】:

    标签: android listview android-widget


    【解决方案1】:

    我通过将第一个 View 更改为 LinearLayout 来解决此问题,之后它似乎工作了。但是,我仍然不确定为什么会这样,如果有人知道,请发表评论。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多