How to add a typeface for ProgressDialog from assets folder?

905 views Asked by At

Given my code below.I want to convert the title "Please wait for the call to be activated" to hindi(font which i have given in assets folder)..

public ShakeEventsListener(Context context, OnShakeListener mShakeListener) {
        this.context = context;
        this.mShakeListener = mShakeListener;
        startTime = 0;
        movecount = 0;
        elapsedTime = 0;

        pDialog = new ProgressDialog(context);
        pDialog.setTitle(" Please wait for the call to be activated");
        pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

        complexPreferences = MyApplication.getComplexPreference();
    }
1

There are 1 answers

0
anshad On BEST ANSWER

By overrideing the setOnShowListner of the DialogInterface.This interface listner is invoked before the dialog is shown.`

((AlertDialog) pDialog).setOnShowListener(new DialogInterface.OnShowListener() {



                @Override
                public void onShow(DialogInterface dialog) {
                    // TODO Auto-generated method stub
                    Log.i("entered","show listner");

                      final int idAlertTitle=getApplicationContext().getResources().getIdentifier( "alertTitle", "id", "android" );
                      TextView textDialog=(TextView)((AlertDialog)dialog).findViewById(idAlertTitle);

                    textDialog.setTypeface(Typeface.createFromAsset(getAssets(), "font/DEVANEW.ttf"));;
                }
            });

Reference Link:How to get the title id of the AlertDialog?