如何从assets文件夹中为ProgressDialog添加字体?

时间:2013-12-02 05:19:00

标签: progressdialog assets typeface

鉴于我的代码如下。我想将标题“请等待呼叫激活”转换为hindi(我在资产文件夹中给出的字体)..

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 个答案:

答案 0 :(得分:1)

通过覆盖DialogInterface的setOnShowListener。在显示对话框之前调用该接口列表器。

((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"));;
                }
            });

参考链接:How to get the title id of the AlertDialog?