Setting a custom font/size for ListActivity
Below is my code which is extended to the ListActivity. I am wishing to
use the custom font/size but apparently this doesn't seem to be working
when I tried getView().
public class Shabad extends ListActivity {
private int shabad = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.mylist,
ShabadActivity.arr));
}
public class MenuItemAdapter extends ArrayAdapter<String>{
//private Typeface font;
public MenuItemAdapter(Context context, int textViewResourceId,
List<String> objects) {
super(context, textViewResourceId, objects);
//font = Typeface.createFromAsset(context.getAssets(),
"AnmolUniBani.ttf");
}
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater=getLayoutInflater();
View row = inflater.inflate(R.layout.mylist, parent, false);
TextView label = (TextView)row.findViewById(R.id.text);
Typeface tf = Typeface.createFromAsset(getAssets(),
"AnmolUniBani.ttf");
label.setTypeface(tf);
label.setTextSize(25);
return view;
}
}
@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("ੰਡਉਤਿ
ਬੰਦਨ ਅਨਿਕ
ਬਾਰ ਸਰਬ ਕਲਾ
ਸਮਰਥ ॥") ||
keyword.equals("ੰਡਉਤਿ
ਬੰਦਨ ਅਨਿਕ
ਬਾਰ ਸਰਬ ਕਲਾ
ਸਮਰਥ ॥")){
shabad = 1;
}
}
}
No comments:
Post a Comment