我有问题,我想为我的列表视图创建一个自定义设计,但我不知道该怎么做。我使用了一个在我的列表视图中的sql数据库。哈哈对不起,我不知道该怎么说这个......因为我是德国人......所以对我的englsih感到抱歉。这里是我的代码:如何更改我的ListView项目的字体?
private void populateListViewFromDB() {
Cursor cursor = myDb.getAllRows();
startManagingCursor(cursor);
String[] fromFieldNames = new String[]
{DBAdapter.KEY_NAME, DBAdapter.KEY_STUDENTNUM, DBAdapter.KEY_FAVCOLOUR, DBAdapter.KEY_STUDENTNUM};
int[] toViewIDs = new int[]
{R.id.item_name, R.id.item_icon, R.id.item_favcolour, R.id.item_studentnum};
SimpleCursorAdapter myCursorAdapter =
new SimpleCursorAdapter(
this,
R.layout.item_layout,
cursor,
fromFieldNames,
toViewIDs
);
// Set the adapter for the list view
ListView myList = (ListView) findViewById(R.id.listViewFromDB);
myList.setAdapter(myCursorAdapter);
}
谢谢你的帮助:)
你必须创建一个自定义适配器来做到这一点.. – 2014-09-30 12:47:55
但我已经使用了一个适配器。这可以工作吗? – 360Productions 2014-09-30 12:48:49
1)你可以设定你想要的任何自定义字体。 2)但是,只有在真正需要时才应该这样做。用户可以在设备的设置中选择他们想要的任何自定义字体。如果你强制使用其他字体,你只会惹恼那些想要自定义字体的字体。 – 2014-09-30 12:48:53