Could someone suggest a way to change font in a dynamically created AlertDialog (in title and body)? I tried in loads of ways, but none of them worked. The code is:
public void onClick(View v) {
new AlertDialog.Builder( c )
.setTitle( data.eqselect )
// .set
.setIcon(R.drawable.icon)
.setMessage(Threads.myData[0] )
.setNegativeButton( "Close", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.d( "AlertDialog", "Negative" );
}
} )
.show();
}
Instead of setting the text of the alertdialog, you should set a custom view form your layouts. And before you do so, modify your view's font.
And to set the view of your alert dialog, call
.setView(mycontent)
instead ofsetMessage()
Although this doesn't change your title as far as I know.Update I'm seeing you're unable to get what I'm saying, so here's a full example
This is using a TextView that we've just created, and it won't have margins or such. If you use a readily created one form your layout files, you'd be able to customize all those settings, although you can do that for this example to in code.
Of course, replace the font with the one you want.. A sample TextView from xml could be: