-2

how i can put font in this code

            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;
                }
            }

i want to add the custom font in the TextView and ListView to make my app stylist in the above code you can see the ListView and TextView in which i want to add the custom font hear

TextView title = (TextView)vi.findViewById(R.id.title);
TextView duration = (TextView)vi.findViewById(R.id.duration); 

this is the two main TextView in which i want to add the custom font

Iamat8
  • 3,888
  • 9
  • 25
  • 35

1 Answers1

0
  1. put the font inside the assets->font->"Your Font Directry"

  2. now suppose you want to add the font in the TextView so do like this

    TextView tv=(TextView)findViewById(R.id.logo_text);
    Typeface face=Typeface.createFromAsset(getAssets(), font/"Your Directry"/Your Font.ttf"); tv.setTypeface(face);

  3. That's all

Rishabh Agrawal
  • 1,998
  • 2
  • 25
  • 40