2 solutions: dynamically or with a custom layout.
Dynamically: you can set a text color by using
setTextColor(...)
when you Override thegetView()
method in your ArrayAdapter, something like this:gridview.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strData) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); TextView text = (TextView) view.findViewById(android.R.id.text1); text.setTextColor(getResources().getColor(R.color.my_color)); return view; } });
Custom Layout: this is the simplest way, build a custom layout as:
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tv" android:layout_height="fill_parent" android:layout_width="fill_parent" android:textColor="@color/my_color" android:background="@drawable/my_background" android:padding="5sp" android:singleLine="true" android:gravity="center" />
Then, set it to your adapter:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.my_layout_above, strData);
Even if, you wanted this dynamically, I'm not sure but I think it's better to do with a custom layout.
Hope this helps.