为什么seekbar在android中太慢了

时间:2013-09-12 13:39:33

标签: android seekbar

我在我的活动和textview中放了一个搜索栏 搜索栏将改变文本视图的字体大小,但如果字符串太大,搜索栏将会如此慢,这是代码,如果有人可以检查它,看看我是否错过了什么或这种缓慢是正常的

public class TextActivity extends Activity {

    public static TextView textview;
    private SharedPreferences prefs;
    private SeekBar seekbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // Remove title bar
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        // Remove notification bar
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        Window window = getWindow();
        // Unlock the device if locked
        window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
        // Turn screen on if off
        window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
        // Keep screen on
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        // Transition between activities
        overridePendingTransition(R.anim.incoming, R.anim.outgoing);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text);
        // Determine The SeekBar and The EditText
        seekbar = (SeekBar) findViewById(R.id.seekBar1);
        textview = (TextView) findViewById(R.id.id_text_txt);
        // Get Extra From Another Activity
                Intent n = getIntent();
                String mrng = n.getStringExtra("key");
                 textview.setText(Html.fromHtml(mrng));
        // Save Preferences
        prefs = getPreferences(MODE_PRIVATE);

        float fs = prefs.getFloat("fontsize", 40);
        seekbar.setProgress((int) fs);
        textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, seekbar.getProgress());

        // Programming SeekBar
        seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                prefs = getPreferences(MODE_PRIVATE);
                SharedPreferences.Editor ed = prefs.edit();
                ed.putFloat("fontsize", textview.getTextSize());
                ed.commit();
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                // nothing
            }

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress,
                    boolean fromUser) {
                textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, progress);
            }
        });
    }
}

任何帮助??

0 个答案:

没有答案