我有一个自定义 ListActivity 作为多项选择题,我正在尝试更改列表中项目的字体。这就是我所拥有的...
public class MultipleChoiceActivity extends ListActivity {
private TextView questionView;
private String[] items = { "a", "b", "c", "d" };
@Override
public void onCreate(Bundle savedInstanceState) {
//do some stuff like populate items array from db
setContentView(R.layout.multichoice_activity);
setListAdapter(new ArrayAdapter(this, R.layout.custom_list_item, items));
questionView = (TextView) findViewById(R.id.question);
Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/Schalk.ttf");
questionView.setText(question);
questionView.setTypeface(typeFace);
}
public void onListItemClick(ListView parent, View v, int position, long id) {
userAnswer = position + 1;
}
因此,我已经能够使用我的资产中的正确字体设置名为“问题”的 TextView,但我无法使用该资产为列表中的元素设置它。有任何想法吗?