I have seen some links which am not able to trace it out.I am trying to change the color of the list item using java code in my activity class. Iam not using any Code for list view in my XML file. So, please Can any one tell me how to change the color of the list item from default white to black and here is my sample code .
ListView listView;
// Create an array of Strings, that will be put to our ListActivity
String[] names = new String[] { "India", "Malaysia" };
// Use your own layout and point the adapter to the UI elements which
// contains the label
TextView tv = new TextView(getApplicationContext());
tv.setText("Select Country");
listView = getListView();
listView.addHeaderView(tv);
listView.setCacheColorHint(Color.rgb(36, 33, 32));
listView.setBackgroundColor(Color.rgb(225, 243, 253));
this.setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,names));
}
Thanks in advance
I don’t think that changing the code in core Android components is a good idea. If you want to try something along the lines suggested by krishna5688, a better idea would probably be to better to create your own simple_expandable_list_item_1.xml (I would suggest giving it a more relevant name).
The SDK version of the layout file can be found in
<your SDK folder>\platforms\android-<whichever version you're using>\data\res\simple_expandable_list_item_1.xml.Put the contents into an xml file in your own res/layout folder, and make the changes there.
Then change the line of code
Note that it’s no longer
android.R.layout…