Click here to Skip to main content
13,091,300 members (52,917 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How to use custom font in listview in android?
Posted 4-Mar-12 5:56am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This StackOverflow question[^] has the answer[^].

Answer states:

You can't do it that way because the text view resource you pass to the ArrayAdapter is inflated each time it is used.

You need to create your own adapter and provide your own view.

An example for your adapter could be
public class MyAdapter extends BaseAdapter {
private List<Object>        objects; // obviously don't use object, use whatever you really want
private final Context   context;
public CamAdapter(Context context, List<Object> objects) {
    this.context = context;
    this.objects = objects;
public int getCount() {
    return objects.size();
public Object getItem(int position) {
    return objects.get(position);
public long getItemId(int position) {
    return position;
public View getView(int position, View convertView, ViewGroup parent) {
    Object obj = objects.get(position);
    TextView tv = new TextView(context);
    tv.setText(obj.toString()); // use whatever method you want for the label
    // set whatever typeface you want here as well
    return tv;

And then you could set that as such
ListView lv = new ListView(this);
lv.setAdapter(new MyAdapter(objs));

Hopefully that should get you going.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100