问题
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