2012-04-02 13 views
1

Ich muss die Schriften meines Projekts zu externen ändern und ich habe es fast überall gemacht, jetzt nur die Titel von ProgressDialog und ErrorDialeg (der Körper ist geändert auch).Android: Abrufen/Abrufen von progressDialog Titel ID und DialegError Titel ID

Also, was ich in beiden Fällen tun (comented Textview aufgrund 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); 

und:

.......... 
    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); 

ich alle Optionen ausprobiert habe ich konnte (nicht nur ‚R.id .title ') und ich habe nur Exceptions, die versuchen, die TITLE TextView in beiden Fällen zu erhalten. Es ist das letzte, was ich brauche, um die Schriften eines ganzen Projekts zu ändern. Wenn jemand weiß, wo man den Titel bekommt ... danke im Voraus.

Antwort

7

für Alertdialog Dieses Versuchen:

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

Und für Alertdialog Knopf Schrift:

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

für ProgressDialog Dieses Versuchen:

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

, dass die Arbeitslösung –

+0

Nullpointer ist –