I'm creating an alert dialog this way:
AlertDialog.Builder alertDialog = new AlertDialog.Builder(view.getContext());
alertDialog.setCustomTitle(null);
alertDialog.setItems(getAllListNames(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//Doing something awesome...
}
});
I know it creates a list view with my items, I want to set a typeface with a custom font for them and also set a max number of characters for each list item, how can I do it?
You have to create a custom theme. Here is the official guide: http://developer.android.com/guide/topics/ui/themes.html :)
Something like this (in the
style.xml
file):Then when you create the dialog you can do this:
Where
R.style.CustomFontTheme
is the id for the them you have created.Update:
Ok, to add your custom typeface you can follow this gist: https://gist.github.com/artem-zinnatullin/7749076
The key is to override the a given font face when the application starts like this:
the gist has the implementation for that method.
So the theme styles should look like this now: