0

我是安卓新手。我需要将自定义字体设置为列表视图吗?

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

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

}

4

1 回答 1

1

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

于 2013-06-21T07:12:50.867 回答