Question

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));       
}

}

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top