I tried changing the font of AlertDialog using this function
private void saveDialog(){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(res.getString(R.string.dialog_title)) .setMessage(res.getString(R.string.dialog_saveconfirm)) .setCancelable(false) .setNegativeButton(res.getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }) .setPositiveButton(res.getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {
When I call the function in Activity, I had 02-25 17:59:04.759: E/AndroidRuntime(1014): java.lang.NullPointerException for tit when setting the font, but working when removing the tit dialog works fine.
I think the error in TextView tit = (TextView) alert.findViewById(android.R.id.title); equal to zero.
How can I solve this problem?
Update This link contains the answer to my question Answer
Thanks Sam
source share