I have implemented an application on ListView in my application i have used getListView() method.I have written code as follows:
String[] conversionsadd = getResources().getStringArray(R.array.conversions);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,conversionsadd));
getListView().setTextFilterEnabled(true);
getListView().setBackgroundResource(R.drawable.listback2);
when i write the above code at onCreate method i can able to show the list with some texts. from the above code i would like to display the text in center in the list and also display the text in a color.
you should give the code of the
getView
function ofArrayAdapter
or XML ofR.layout.simple_list_item_1
, which is normally where the style of the listview item is setI didnot try, but I think, overriding getView in adapter method, and do the following:
you are using built-in layout which is
this layout cannot be changed. However you can provide your own row layout.
your row should look like this:
remember that the id should be only
android:id="@android:id/text1"
and now you can give this to your ArrayAdapter's constructor: