I have developed an Andriod RSS reader app.I have used custom listview to list RSS titles and its images.Now I want to change the font of RSS titles.How can I set typeface to my title textview?
Here is my adapter class in which I am setting the title Textview.
Adapter.java
public class InternationalAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public InternationalAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
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); // For this Textview I want to set Typeface.
TextView date = (TextView)vi.findViewById(R.id.artist);
ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image);
HashMap<String, String> news = new HashMap<String, String>();
news = data.get(position);
// Setting all values in listview
title.setText(International.Title[position]);
date.setText(International.Date[position]);
imageLoader.DisplayImage(International.image[position], thumb_image);
return vi;
}
}
You can use this,
you can use this:)
We can also use this method:
Here monospace is a typeface.
Try like this
use custome textview as given below and set font there
and in your listview row xml means in list_row layout add textview as
here more property are used u can remove which not required and in your getview method define it as
You can use this library to change font on any view, only need to pass font file name with the binding xml code. https://github.com/ChathuraHettiarachchi/TypeFaced
1.textview
2.edittext
3.switch
4.toggle
5.button
6.radiobutton
7.checkbox