[英]Custom widget ListView not working properly
我有一個帶有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
?
謝謝!
我通過將第一個View
更改為LinearLayout
來解決此問題,此后它似乎可以工作了。 但是,我仍然不確定為什么會這樣,如果有人知道,請發表評論。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.