简体   繁体   English

通过首选项更改文本大小

[英]Change Text Size through preferences

I was wondering if anyone could help me with a question. 我想知道是否有人可以帮助我解决问题。

How would I change the text size of a textView depending on preferences? 如何根据首选项更改textView的文本大小? within my preferences I have a radiogroup and would like the text size to change based on which radio button is checked. 在我的首选项中,我有一个无线电组,并且希望根据选中哪个单选按钮来更改文本大小。 I have came up with the following but this does not work. 我想出了以下方法,但这不起作用。

SharedPreferences getData = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String values = getData.getString("list", "4");

    if (values.contentEquals("1")){
        tv1.setTextSize(20);
    }

The following is for the menu I want to change: 以下是我要更改的菜单:

setListAdapter(new ArrayAdapter<String>(MainMenu.this, R.layout.mylist, classes));

probably you didn't declare the list parameter right in your SharedPreferences . 可能您没有在SharedPreferences正确声明list参数。

My bet is that getString return 4 because "list" doesn't has a value. 我敢打赌, getString返回4,因为“ list”没有值。

so what heppens if you change to: 因此,如果您更改为:

 if (values.contentEquals("4")){
        tv1.setTextSize(20);
    }

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

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