zoukankan      html  css  js  c++  java
  • 字体大小

    private void getzitidaxiao() {
    
    // 创建数据
            final String[] titlle2 = new String[]{"", "", "", "特大"};
    
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
    
            builder.setTitle("字体大小")
                    .setSingleChoiceItems(titlle2, 0, new DialogInterface.OnClickListener() {
    
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
    
                            if (which == 0) {
                                textzt.setText(titlle2[which]);
    
                                getSharedPreferences("ALER", MODE_PRIVATE).edit().putInt("font", 0).commit();
                                alertDialog.dismiss();
                            } else if (which == 1) {
                                textzt.setText(titlle2[which]);
                                getSharedPreferences("ALER", MODE_PRIVATE).edit().putInt("font", 1).commit();
                                alertDialog.dismiss();
                            } else if (which == 2) {
                                textzt.setText(titlle2[which]);
                                getSharedPreferences("ALER", MODE_PRIVATE).edit().putInt("font", 2).commit();
                                alertDialog.dismiss();
                            }
                            if (which == 3) {
                                textzt.setText(titlle2[which]);
                                getSharedPreferences("ALER", MODE_PRIVATE).edit().putInt("font", 3).commit();
                                alertDialog.dismiss();
                            }
    
                        }
    
                    });
    
            builder.setPositiveButton("取消", null);
    
             alertDialog = builder.create();
            alertDialog.setCanceledOnTouchOutside(true);
            alertDialog.show();
        }

    适配器  tv要更改的TextView

    if (anInt == 0) {
                    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, 15); //设置45PX
                    notifyDataSetChanged();
                } else if (anInt == 1) {
                    tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30); //设置45SP
                    notifyDataSetChanged();
                } else if (anInt == 2) {
                    tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 46); //设置45SP
                    notifyDataSetChanged();
                } else if (anInt == 3) {
                    tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 58);//设置45DIP
                    notifyDataSetChanged();
                }

    获取

    int anInt = context.getSharedPreferences("ALER",MODE_PRIVATE).getInt("font", 0);
  • 相关阅读:
    js-计算器
    正确看待HTML5的语法变化
    什么是Web前端,Web前端是做什么的?
    css复合属性的写法
    Unicode与JavaScript详解
    input 定宽,文本超出后缩小字体,尽可能多的显示文本
    手机号中间四位加*号
    React 状态和生命周期
    还是数组 练习题 而已
    数组 练习题 而已
  • 原文地址:https://www.cnblogs.com/shangliang88/p/7566844.html
Copyright © 2011-2022 走看看