Memory increase on each orientation change, using two different layouts

时光怂恿深爱的人放手 提交于 2019-12-25 01:19:14

问题


I'm using different layouts for portrait and landscape modes. Is memory increasing each time orientation is changed if I'm using two different layouts? How to use same memory or free activity memory load previously? I used:

<activity android:name=".LoginOnline"
 android:configChanges="orientation|keyboardHidden" >

in activity in manifest file and override onconfigurationchanged method to prevent activity recreate but memory is still not released!

public void onConfigurationChanged(Configuration newConfig) {
    String userr = user.getText().toString();
    String passs = pass.getText().toString();
    boolean rme = rememberme.isChecked();
    setContentView(R.layout.loginonline);
    login = (Button) findViewById(R.id.loginonline);
    user = (EditText) findViewById(R.id.username);
    pass = (EditText) findViewById(R.id.password);
    rememberme = (CheckBox) findViewById(R.id.remeberme);
    user.setText(userr);
    pass.setText(passs);
    rememberme.setChecked(rme);
    login.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            login(user.getText().toString(), pass.getText().toString());
            if (rememberme.isChecked()) {
                saveLoginDetails();
            } else {
                removeLoginDetails();
            }
        }
    });
    super.onConfigurationChanged(newConfig);
}

But still the memory increases each time the orientation changes. Why?

来源:https://stackoverflow.com/questions/12006040/memory-increase-on-each-orientation-change-using-two-different-layouts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!