安卓:获得/检索progressDialog标题的ID和DialegError称号的ID [英] Android: get/retrieve progressDialog title's ID and DialegError title's ID

查看:174
本文介绍了安卓:获得/检索progressDialog标题的ID和DialegError称号的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须改变我的项目外部因素的字体和我已经做到了几乎无处不在,现在只有它缺少标题的ProgressDialog和ErrorDialeg(身体变化太大)。

I must change the fonts of my project to external ones and i've done it almost everywhere, now only it's missing the Title's of ProgressDialog and ErrorDialeg (the body is changed too).

所以,我做的这两种情况下(comented的TextView由于异常):

So what i do in both cases (comented textview due to Exception):

        String msg1 = "one", msg2 = "two";

        progressDialog = ProgressDialog.show(activity, msg1, msg2, true);
        Typeface font=Typeface.createFromAsset(activity.getAssets(),"fonts/rockwell.ttf");

        TextView text = (TextView)progressDialog.findViewById(android.R.id.message);
        text.setTypeface(font);

        //text = (TextView)progressDialog.findViewById(android.R.id.title);
        text.setTypeface(font);

    ..........
    AlertDialog dialog = new AlertDialog.Builder(a)
        .setTitle( titol )
        .setMessage( cos )
    ..........
        .show();

     //Establir el canvi de font a la personalitzada.
     Typeface font=Typeface.createFromAsset(a.getAssets(),"fonts/rockwell.ttf");
     TextView textView = (TextView)dialog.findViewById(android.R.id.message);
     textView.setTypeface(font);
     //textView =  (TextView)dialog.findViewById(android.R.id.title);
     textView.setTypeface(font);
     textView =  (TextView)dialog.findViewById(android.R.id.button1);
     textView.setTypeface(font);

我已经尝试了所有的选项,我可以(不只是'R.id.title'),我只得到了异常试图拿到冠军TextView的在两种情况下。这是过去的事情,我需要改变整个项目的字体。 如果有谁知道从哪里得到的标题... 在此先感谢。

I've tried all options I could (not only 'R.id.title') and I only got Exceptions trying to get the TITLE TextView in both cases. It's the last thing i need to change whole project's fonts. If anyone knows where to get the Title... thanks in advance.

推荐答案

有关AlertDialog试试这个:

for AlertDialog Try This :

((TextView) dialog.findViewById(getResources().getIdentifier(
            "alertTitle", "id", "android"))).setTypeface(myRegularFont);

和AlertDialog按钮字体:

And For AlertDialog Button TypeFace :

((Button) dialog.getButton(AlertDialog.BUTTON_POSITIVE))
            .setTypeface(myBoldFont);

有关ProgressDialog试试这个:

for ProgressDialog Try This :

((TextView) prWait.findViewById(getResources().getIdentifier(
                "alertTitle", "id", "android"))).setTypeface(myRegularFont);

这篇关于安卓:获得/检索progressDialog标题的ID和DialegError称号的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆