简体   繁体   中英

Custom widget ListView not working properly

I have a widget with a ListView, that has custom list items, implemented with RemoteViewsService.RemoteViewsFactory . My layout code is this:

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

The problem with this layout is that it's not working, it displays "Loading..." for every list item. The thing is, if i remove the first View that acts just as a design element and adds a coloured bar at the begining of each item.... it works. How can i make it work with the first View ?

Thanks!

I fixed this by changing the first View to a LinearLayout , it seemed to work after that. However, i am still not sure why this works, if anyone knows, please leave a comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM