1

I want to change the font of AlertDialog.Builder's object. my AlertBuilder is inside webview content. here is my code:

webView.addJavascriptInterface(new Object() {
            @JavascriptInterface // For API 17+
            public void performClick(String strl) {



            AlertDialog.Builder dialog = new AlertDialog.Builder(
                    new ContextThemeWrapper(FacebookSlider.this, R.style.AlertDialogCustom));



            dialog.setMessage(strl);
            dialog.show();



        }
    }, "ok");

I read this link but it didn't work for AlertDialog.Builder. what should i do?

Community
  • 1
  • 1
MSepehr
  • 890
  • 2
  • 13
  • 36
  • Whats the problem you are getting when you are setting TypeFace , and have you provided the custom font in folder name asset – Sanjeev Aug 24 '15 at 04:12
  • @ L-X 6,setting TypeFace to what?`dialog.findViewById(android.R.id.message)` in method in mentioned link do not work for `AlertDialog.Builder` to set typeface . – MSepehr Aug 24 '15 at 04:18
  • 1
    you can use a custom layout for this dialog and in the custom layout change the TypeFace of textView – Sanjeev Aug 24 '15 at 04:23
  • i use this link : http://stackoverflow.com/questions/22655599/alertdialog-builder-with-custom-layout-and-edittext-cannot-access-view – MSepehr Aug 24 '15 at 04:36

1 Answers1

0

I use this link and change my code to :

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(
                        new ContextThemeWrapper(FacebookSlider.this, R.style.AlertDialogCustom));
                // ...Irrelevant code for customizing the buttons and title
                LayoutInflater inflater = FacebookSlider.this.getLayoutInflater();
                View dialogView = inflater.inflate(R.layout.alert_label_editor, null);
                dialogBuilder.setView(dialogView);

                TextView alrttext = (TextView) dialogView.findViewById(R.id.alertmessage);
                alrttext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/byekan.ttf"));
                alrttext.setText(strl);
                AlertDialog alertDialog = dialogBuilder.create();
                alertDialog.show();
Community
  • 1
  • 1
MSepehr
  • 890
  • 2
  • 13
  • 36