OSDN Git Service

Clear out old views when setting new content in settings
authorJason Monk <jmonk@google.com>
Wed, 30 Mar 2016 15:05:51 +0000 (11:05 -0400)
committerJason Monk <jmonk@google.com>
Wed, 30 Mar 2016 16:35:29 +0000 (12:35 -0400)
Bug: 27529989
Change-Id: Id44ca442c2117bc5df7929bcd79434c0ae23cded

packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java

index c3a5089..ff70190 100644 (file)
@@ -176,8 +176,11 @@ public class SettingsDrawerActivity extends Activity {
 
     @Override
     public void setContentView(@LayoutRes int layoutResID) {
-        LayoutInflater.from(this).inflate(layoutResID,
-                (ViewGroup) findViewById(R.id.content_frame));
+        final ViewGroup parent = (ViewGroup) findViewById(R.id.content_frame);
+        if (parent != null) {
+            parent.removeAllViews();
+        }
+        LayoutInflater.from(this).inflate(layoutResID, parent);
     }
 
     @Override