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

3

给定以下代码。我想将标题“请等待呼叫激活”转换为印地语(我在assets文件夹中提供了字体)。

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个回答

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

参考链接: 如何获取AlertDialog的标题ID?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接