2016-11-27 96 views
0

我有這兩個代碼(兩項活動)了java.lang.RuntimeException:本地字體無法進行,並自定義字體

MainActivity

namespace App16 
{ 
    [Activity(Label = "App16", MainLauncher = true, Icon = "@drawable/icon")] 
    public class MainActivity : Activity 
    { 
     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 

      // Set our view from the "main" layout resource 
      SetContentView(Resource.Layout.Main); 
      TextView tv = FindViewById<TextView>(Resource.Id.textView1); 

      Button button = FindViewById<Button>(Resource.Id.button1); 
      var activity2 = new Intent(this, typeof(Activity1)).SetFlags(ActivityFlags.ReorderToFront); 
      string[] str = new string[2]; 
      str[0] = "hello"; str[1] = "سلام"; 
      activity2.PutExtra("MyData", str); 
      button.Click += delegate 
      { 
       StartActivity(activity2); 
      }; 
     } 
    } 
} 

活動

namespace App16 
{ 
    [Activity(Label = "Activity1")] 
    public class Activity1 : Activity 
    { 
     protected override void OnCreate(Bundle savedInstanceState) 
     { 
      base.OnCreate(savedInstanceState); 

      // Create your application here 
      SetContentView(Resource.Layout.Main2); 
      string[] text = Intent.GetStringArrayExtra("MyData"); 
      TextView tvE = FindViewById<TextView>(Resource.Id.textView3); 
      TextView tvP = FindViewById<TextView>(Resource.Id.textView2); 
      Typeface typeP = Typeface.CreateFromAsset(this.Assets, "fonts/blotus.ttf"); 
      tvP.SetTypeface(typeP, TypefaceStyle.Normal); 
      if (text[0] == "hello") 
      { 
       tvE.Text = text[0]; 
       tvP.Text = text[1]; 
      } 
     } 
    } 
} 

這些工作得很好,但是當我在另一個程序中使用這些時,我有這個錯誤:

Java.Lang.RuntimeException: native typeface cannot be made

我不知道爲什麼?

回答

0

我將字體改爲大寫字母,問題解決了: BLOTUS.TTF