【问题标题】:How to set the custom font to dynamically created listView?如何将自定义字体设置为动态创建的 listView?
【发布时间】:2013-06-21 15:12:50
【问题描述】:

我是安卓新手。我需要将自定义字体设置为 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));       
}

}

【问题讨论】:

    标签: android listview fonts android-fonts


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-05
      • 2022-12-23
      相关资源
      最近更新 更多