2016-12-30 7 views
0

ProgressDialogの書体を変更する必要があります。Android:不確定なProgressDialogのメッセージの書体を変更するには

私は水平スタイルprogressDialogの書体をこのように変更することができます。

   progressProzent = new ProgressDialog(mActivity); 
      if (passUrlVector.size() > 1) { 
       progressProzent.setTitle(mActivity.getString(R.string.Lade_Tickets)); 
       String message = String.format(mActivity.getString(R.string.Tickets_Werden_heruntergeladen), passUrlVector.size()); 
       progressProzent.setMessage(message); 
      } else { 
       progressProzent.setTitle(mActivity.getString(R.string.Lade_Ticket)); 
       progressProzent.setMessage(mActivity.getString(R.string.Ticket_Wird_heruntergeladen)); 
      } 
      progressProzent.setIndeterminate(false); 
      progressProzent.setProgressNumberFormat(null); 
      progressProzent.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); 
      progressProzent.setCancelable(false); 
      progressProzent.show(); 
      try { 
       TextView textView = (TextView) progressProzent.findViewById(android.R.id.message); 
       textView.setTypeface(TypefaceUtil.georgia); 
      } catch (Exception e) { 
       Log.i("PROGRESS", "Exception = ", e); 
      } 

私は不確定ProgressDialogこの方法のタイトルの書体を変更することができます。

  progress = new ProgressDialog(this); 

     progressShowListener = new DialogInterface.OnShowListener() { 
      @Override 
      public void onShow(DialogInterface dialog) { 
       Log.i("entered", "show listner"); 
       try { 
        final int idAlertTitle=getApplicationContext().getResources().getIdentifier("alertTitle", "id", "android"); 
        TextView dialogTitle=(TextView)((AlertDialog)dialog).findViewById(idAlertTitle); 

        dialogTitle.setTypeface(TypefaceUtil.neutraBurgDemi); 

        TextView textView = (TextView) progress.findViewById(android.R.id.message); 
             textView.setTypeface(TypefaceUtil.georgia); 
       } catch (Exception e) { 
        Log.i("PROGRESS", "Exception = ", e); 
       } 
      } 
     }; 
     progress.setOnShowListener(progressShowListener); 

しかし、メッセージの書体ジョージアフォントに変更されません。それをどうすれば実現できますか?

答えて

0
progressDialog = new ProgressDialog(context):  
    progressDialog.show(); 
    TextView tv1 = (TextView) progressDialog.findViewById(android.R.id.message); 
    tv1.setTypeface(yourCustomTF); 

あなたはprogressDialog.show後findViewByIdを()()ビューはショーの後に生成されるので、()を使用して、ビューIDを取得することができ、覚えておいてください。

+0

解決策は、水平方向のスタイルProgressDialogに対してのみ機能しますが、スピンナースタイルの不確定なProgressDialogでは機能しません。 –

関連する問題