我怎么能把字体放在这段代码中
public class AndalosAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
int imageResource;
public AndalosAdapter(Activity a, ArrayList<HashMap<String, String>> d, int imageResource) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.imageResource = imageResource;
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_row, null);
TextView title = (TextView)vi.findViewById(R.id.title);
TextView duration = (TextView)vi.findViewById(R.id.duration);
ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image
HashMap<String, String> song = new HashMap<String, String>();
song = data.get(position);
title.setText(song.get(AndalosList.KEY_TITLE));
artist.setText(song.get(CustomizedListView.KEY_ARTIST));
duration.setText(song.get(AndalosList.KEY_DURATION));
thumb_image.setImageResource(imageResource);
return vi;
}
}
我想在TextView
和ListView
中添加自定义字体,以便在上面的代码中创建我的应用设计师,您可以看到ListView
和TextView
想要添加自定义字体听
TextView title = (TextView)vi.findViewById(R.id.title);
TextView duration = (TextView)vi.findViewById(R.id.duration);
这是我要添加自定义字体的两个主要TextView
答案 0 :(得分:0)
将字体放在assets->font->"Your Font Directry"
现在假设你要在TextView
中添加字体,所以这样做
TextView tv=(TextView)findViewById(R.id.logo_text);
Typeface face=Typeface.createFromAsset(getAssets(),
font/"Your Directry"/Your Font.ttf");
tv.setTypeface(face);
这就是