Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make a widget scrollable under Android 4.0?
    primarykey
    data
    text
    <p>I have a working pre Android 4 widget that shows a list of items. Each items has a color patch that shows one of three colors and text whose color and style are determined by attributes of the app data. The list is implemented as a vertical LinearLayout but I want to convert it to ListView to make the widget scrollable in ICS. I could not figure out though how to map the underlying item data properties to the item remote view, when using a ListView.</p> <p>(code below is simplified).</p> <p>The item data class is</p> <pre><code>class ItemData { String text; int textColor; int patchColor; } </code></pre> <p>The widget top layout is</p> <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/widget_top_view" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;LinearLayout android:id="@+id/widget_item_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; // Items are added here at runtime by my widget provider class. &lt;/LinearLayout&gt; &lt;/FrameLayout&gt; </code></pre> <p>And each item view uses this layout</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" &gt; &lt;FrameLayout android:id="@+id/widget_item_color" // background color is set at runtime by the widget provider based // on patchColor member of the item data. android:layout_width="6dip" android:layout_height="fill_parent" &gt; &lt;/FrameLayout&gt; &lt;TextView android:id="@+id/widget_item_text_view" android:layout_width="fill_parent" android:layout_height="fill_parent" // Actual color is set at runtime by the widget provider based on // item data. android:textColor="@color/color_place_holder" android:background="@android:color/transparent" // May be set at runtime to false, based on user's prefernces. android:singleLine="true" android:scrollHorizontally="false" android:ellipsize="end" &gt; &lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>My question is, if I change the LinearLayout in the top layout to a ListView, where do I plug in the logic to map item data to item view properties? Any sample code that does similar mapping?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload