如何设置自定义字体动态创建listView?

时间:2013-06-21 07:09:42

标签: android listview fonts android-fonts

我是android的新手。我需要将自定义字体设置为listview?

如何设置字体? 我的代码:

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

}

1 个答案:

答案 0 :(得分:1)

您必须创建自定义适配器,并设置适配器中项目的字体。请参阅此示例:custom font in android ListView