繁体   English   中英

如何进行多种字体样式选择(Typeface & SharedPreferences)

[英]How make several font style selection (Typeface & SharedPreferences)

我不知道如何使用 sharedpreferences 存储字体样式,或者如果有任何其他方法,请支持我。

 // Load Text Font start

    SharedPreferences myTextFont = this.getSharedPreferences("MyTextFont", MODE_PRIVATE);
    textFont = myTextFont.getInt("font", textExample.getTypeface().getStyle());

    textView3.setTypeface(null,textFont);

    // Load Text Font end

   //textExample.setTypeface(textFont);

    //Font Buttons start

    final Typeface typeface1 = ResourcesCompat.getFont(this,R.font.teqnikuri);
    type_1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            textExample.setTypeface(typeface1);

            SharedPreferences myTextFont = getSharedPreferences("MyTextFont", MODE_PRIVATE);
            SharedPreferences.Editor editor = myTextFont.edit();
            editor.putInt("font",  textExample.getTypeface().getStyle());
            editor.commit();

        }
    });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM