Note that there are some explanatory texts on larger screens.

plurals
  1. POListView - show top-most item in other color
    primarykey
    data
    text
    <p>I am writing an Android application which is controlled by a RCU, instead of by touch events/fingers. This RCU has an UP, DOWN, LEFT, RIGHT and OK key (simplified). This means that the OK button is processed on the currently highlighted graphical object. Just think about an interface of an old DVD player, for example.</p> <p>I am trying to adapt the ListView for this purpose. Say I want to present a vertical list of 5 options:</p> <ul> <li>Yes (red)</li> <li>Maybe (white)</li> <li>Certainly (white)</li> <li>Possibly (white)</li> <li>Never (white)</li> </ul> <p>Initially, the first option, Yes, should be in some color (the highlight/focus color), whereas the other 4 options are in another color (default color).</p> <p>When the user presses UP, Maybe is translated to the top and is displayed in the highlight/focus color; Yes is added on the bottom of the list, and is displayed in the default color:</p> <ul> <li>Maybe (red)</li> <li>Certainly (white)</li> <li>Possibly (white)</li> <li>Never (white)</li> <li>Yes (white)</li> </ul> <p>The possible options are provided to the ListView via an ArrayAdapter:</p> <pre><code> public class DetailOptionsItemAdapter extends ArrayAdapter&lt;String&gt; { public DetailOptionsItemAdapter(Context context, String[] options) { super(context, R.layout.options, options); } } </code></pre> <p>In constructor of class which derives ListView:</p> <pre><code> setAdapter(new DetailOptionsItemAdapter(getContext(), new String[]{"Yes", ...}))); </code></pre> <p>My layout (R.layout.options) is defined as following:</p> <pre><code>&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:textColor="@color/white" android:textColorHighlight="@color/red" android:includeFontPadding="true" android:ellipsize="end" android:singleLine="true"/&gt; </code></pre> <p>When UP or DOWN is received, I translate the requested index to the top:</p> <pre><code> smoothScrollToPositionFromTop(... the index ..., 0); </code></pre> <p>This works. So far, everything is displayed in white, the default color.</p> <p>Now I need to plug in that the first item is always red. I tried getting the view at the old position and giving it a while color, and getting the view at the new position and giving it a red color, but without succes.</p> <p>Any idea? Thanks!</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.
 

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