Java.Lang.RuntimeException:无法生成本机字体和自定义字体

时间:2016-11-27 15:27:27

标签: c# android fonts

我有这两个代码(两个活动)

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:无法生成本机字体

我不知道为什么?

1 个答案:

答案 0 :(得分:0)

我将字体的字母改为大写字母,问题解决了: BLOTUS.TTF