Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ListView with different colors
    primarykey
    data
    text
    <p>I am having a little problem using different colors in a <code>ListView</code>.</p> <p>I have tried several things but nothing seems to work</p> <p>private class GameRowAdapter extends ArrayAdapter { ArrayList objects;</p> <pre><code> public GameRowAdapter(Context context, int textViewResourceId, ArrayList&lt;RowModel&gt; objects) { super(context, textViewResourceId, objects); this.objects = objects; } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; RowModelViews model; if (row == null) { LayoutInflater inflater = LayoutInflater.from(GamePlayerActivity.this); row = inflater.inflate(R.layout.game_line_layout, null); model = new RowModelViews(); model.entry = (TextView) row.findViewById(R.id.gameLineEntry); model.score = (TextView) row.findViewById(R.id.gameLineEntryScore); row.setTag(model); } else { model = (RowModelViews) row.getTag(); } if (position == 6 || position == 7) { row.setBackgroundColor(R.color.black); } else { row.setBackgroundColor(R.color.light_transparent); } model.entry.setText(objects.get(position).entry); model.score.setText(objects.get(position).score); return row; } } static class RowModelViews { TextView entry; TextView score; } static class RowModel { String entry; String score; public RowModel(String entry, String score) { this.entry = entry; this.score = score; } } </code></pre> <p>Anyone who can tell me, what I am doing wrong?</p> <p>Thank you.</p> <p><strong>UPDATE</strong></p> <p>Here is the xml of the inflatet row</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/gameLineEntry" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_marginLeft="20dp" android:textSize="20dp" android:gravity="center_vertical"/&gt; &lt;TextView android:id="@+id/gameLineEntryScore" android:layout_height="fill_parent" android:layout_width="65dp" android:layout_marginRight="20dp" android:gravity="center" style="@style/Button" android:layout_gravity="right"/&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    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