Skip to content

Instantly share code, notes, and snippets.

@NLMartian
Created November 22, 2013 16:43
Show Gist options
  • Save NLMartian/7602972 to your computer and use it in GitHub Desktop.
Save NLMartian/7602972 to your computer and use it in GitHub Desktop.
Activity父类中加入子类内容的方法
@Override
public void setContentView(int rootViewId) {
LayoutInflater inflator = getLayoutInflater();
ViewGroup allContent = (ViewGroup)inflator.inflate(R.layout.base_authenticated_screen, null);
ViewGroup content = ((ViewGroup)allContent.findViewById(R.id.screen_content)); // R.id.screen_content是放置子类内容的ViewGroup
content.removeAllViews();
content.addView(inflator.inflate(rootViewId, null));
super.setContentView(allContent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment