我在我的活动中放了一个搜索栏和一个文本视图,搜索栏会改变文本视图的字体大小,但是如果字符串太大,搜索栏会很慢,这是代码请如果有人可以检查它,看看我有没有错过了什么或这种缓慢是正常的
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);
}
});
}
}
有什么帮助吗??