我有ListView。它包含3個不是來自activity_main.xml的TextView。更改不在activity_main.xml中的TextView字體
cursor = myDatabase.getJoinedInfo(etSearch.getText().toString().trim());
String[] columns = new String[] { "re_value", "g_value", "ke_value" };
int[] to = new int[] { R.id.tvHiragana, R.id.tvMeaning, R.id.tvKanji };
dataAdapter = new SimpleCursorAdapter(this, R.layout.wordonlist,
cursor, columns, to, 0);
// Assign adapter to ListView
listView.setAdapter(dataAdapter);
如何更改ListView中TextViews的字體?
final Typeface mFont = Typeface.createFromAsset(getAssets(),
"fonts/himaji.otf");
LayoutInflater ltInflater = getLayoutInflater();
View view = ltInflater.inflate(R.layout.wordonlist, null, false);
tvHiragana=(TextView) view.findViewById(R.id.tvHiragana);
tvHiragana.setTypeface(mFont);
此代碼不能改變的TextView的字體。我做錯了什麼?
所以'wordonlist.xml'是列表項佈局文件...正確嗎? – Squonk
要使用存儲在「assets」中的字體,您需要編寫一個自定義適配器。 – Vikram