Change the text color of the array element in listview

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Change the text color of the array element in listview

Postby poch » Thu Dec 03, 2009 4:44 am

Here is my Problem:

I need to pass sring array through listview and display that array elements on screen.Here the text color of string elements is white . I just change the background color of the listview to black then evrything is fine.

But my requirement is display the string elements in white background with black text color. And reduce the display space between each String array element.

I hope anyone do reply.
Junior Developer
Junior Developer
Posts: 11
Joined: Sun Nov 29, 2009 5:55 pm
Location: INDIA


Postby Syl » Sat Dec 05, 2009 12:38 am

Did you try to modify the adapter that renders the list item views ?

- Create your own adapter (extends ArrayAdapter for example)
- Override the getView() method
-> Create a TextView
-> Apply your graphical modification (setBackgroundColor(...) and setTextColor(...) ) to this TextView
-> Set text, depending of the position (setText( m_dataList[ p_position ] ) )
-> return the text view

- Associated the adapter with the ListView (setAdapter(...))
Junior Developer
Junior Developer
Posts: 14
Joined: Wed Oct 21, 2009 11:03 am

Postby saamyandroid » Mon Dec 07, 2009 1:25 pm

can u give code to change text color of selected Text
Experienced Developer
Experienced Developer
Posts: 84
Joined: Wed Sep 09, 2009 8:17 pm
Location: INDIA


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests