无法解析方法setTypeface(android.graphics.Typeface)

时间:2015-07-27 19:14:49

标签: java android

我正在尝试为AlertDialog设置自定义字体系列,但Android指出以下内容:

Cannot resolve method setTypeface(android.graphics.Typeface)

以下是我的代码:

TextView settingsTitle =  new TextView(this);
        settingsTitle.setText("Settings");
        settingsTitle.setPadding(20, 20, 20, 20);
        settingsTitle.setTextSize(20);
        settingsTitle.setTypeface(Typeface.MONOSPACE);

        AlertDialog settingsDialog = new AlertDialog.Builder(this)
                .setCustomTitle(settingsTitle)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // continue with delete
                    }
                })
                .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        // do nothing
                    }
                })
                .setIcon(android.R.drawable.ic_dialog_alert)
                .show();

        Typeface standardFont = Typeface.MONOSPACE;
        settingsDialog.setTypeface(standardFont);

0 个答案:

没有答案