我有一个类扩展到我想为其设置自定义字体的 ListActivity。任何人都可以帮我完成这个吗?我知道如何使用 TextView 的字体,但不知道如何使用 ListActivity。
public static class PunjabiBooks extends ListActivity{
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
String[] mathList = new String[] {"Gurmukh Soch", "Books (Punjabi)", "Books (Hindi)", "Books (English)",
"Annual Report"};
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mathList));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
if (keyword.equals("Gurmukh Soch")){
x = 0;
try{
Class ourClass = Class.forName("sukrit.trust.PublicationsTab$WebActivity");
Intent ourIntent = new Intent(PunjabiBooks.this, ourClass);
startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}else if(keyword.equals("Books (Punjabi)")){
try{
Class ourClass = Class.forName("sukrit.trust.Publications$PunjabiBooks");
// Intent ourIntent = new Intent(Publications.this, ourClass);
//startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}else if(keyword.equals("Books (Hindi)")){
try{
Class ourClass = Class.forName("sukrit.trust.PublicationsTab$HindiBooks");
// Intent ourIntent = new Intent(Publications.this, ourClass);
// startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}else if(keyword.equals("Books (English)")){
try{
Class ourClass = Class.forName("sukrit.trust.PublicationsTab$EnglishBooks");
// Intent ourIntent = new Intent(Publications.this, ourClass);
// startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}else if(keyword.equals("Annual Report")){
try{
Class ourClass = Class.forName("sukrit.trust.PublicationsTab$AnnualReport");
// Intent ourIntent = new Intent(Publications.this, ourClass);
// startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}