Reputation: 4691
I am newbie to android. I need to set the custom font to listview?
How to set the font? My code:
public class MainActivity extends ListActivity {
String[] presidents = { "Dwight D. Eisenhower", "John F. Kennedy",
"Lyndon B. Johnson", "Richard Nixon", "Gerald Ford",
"Jimmy Carter", "Ronald Reagan", "George H. W. Bush",
"Bill Clinton", "George W. Bush", "Barack Obama"
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ---no need to call this---
// setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, presidents));
}
}
Upvotes: 0
Views: 1221
Reputation: 937
You will have to create a custom adapter, and set the font of the items in the adapter. See this for an example: custom font in android ListView
Upvotes: 1