How to change the color of an array index in android? -


this question has answer here:

i want change color of particular array index , have following array -:

string [] all={"1","2","3","4","5","6","7","8","9","10"};   gridview gridview = (gridview) findviewbyid(r.id.gridview);   arrayadapter<string> adapter = new arrayadapter<string>(this,               android.r.layout.simple_list_item_1, all);                 gridview.setadapter(adapter);        new arrayadapter<string>(this, r.layout.item_layout);        gridview.setchoicemode(1);        gridview.setitemchecked(6, true); 

xml code -: item_layout.xml

      <?xml version="1.0" encoding="utf-8"?>        <textview xmlns:android="http://schemas.android.com/apk/res/android"          android:id="@android:id/text1"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:gravity="center_vertical"         android:paddingleft="16dp"         android:paddingright="16dp"         android:textcolor="#f00"       /> 

i have tried change color of index 6 red it's printing in black color. please me out , how can change color of index 6 red , other black.

i want print resultant array through arrayadapter only.

thank in advance !!!

  1. change data source include items' colors. might done via custom data item class.

  2. create own subclass of arrayadapter. in getview() of adapter, inflate xml, fill data , set background color according data source.#

a tutorial this started.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -