我有一个带有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
?
谢谢!
答案 0 :(得分:0)
我通过将第一个View
更改为LinearLayout
来修复此问题,之后似乎工作正常。但是,我仍然不确定为什么会这样,如果有人知道,请发表评论。