我想更改对话框中 textview 中的字体:
dialog = new Dialog(MyActivity.this);
dialog.setContentView(R.layout.my_dialog);
dialog.setCancelable(true);
((TextView)findViewById(R.id.dialog_box_title_text)).setTypeface(Typeface.createFromAsset(getAssets(), "font.ttf"));
但是每次我得到运行时异常:
E/AndroidRuntime(4475): java.lang.IllegalStateException: Could not execute method of the activity
你知道哪里出了问题吗?因为通常它工作正常。只有在尝试更改对话框中的字体时才会出现问题。
最佳答案
试试这个,让我知道会发生什么。
((TextView)dialog.findViewById(R.id.dialog_box_title_text)).setTypeface(Typeface.createFromAsset(getAssets(), "font.ttf"));
关于android - 在 Android 对话框中设置自定义字体 (TypeFace),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8211198/