My MainActivity extends BaseActivity. Inside my BaseActivity, I override setContentView(int layoutResId)
(refer below) so that when my MainActivity calls setContentView(R.layout.activity_main)
, the view component inside BaseActivity -- the activityContainer
will contain R.layout.activity_main
as its child after the method getLayoutInflater().inflate(layoutResID, activityContainer, true);
is called. How can I achieve the same thing if I want to override setContentView(View view)
instead of setContentView(int layoutResId)
in BaseActivity?
Edit: What are the differences between these two methods?
Inside BaseActivity:
@Override
public void setContentView(int layoutResId) {
RelativeLayout baseActivity = (RelativeLayout) getLayoutInflater()
.inflate(R.layout.activity_base, null);
FrameLayout activityContainer = (FrameLayout) baseActivity
.findViewById(R.id.activity_container);
getLayoutInflater().inflate(layoutResID, activityContainer, true);
}
activity_base.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<FrameLayout
android:id="@+id/activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
.... other components
</RelativeLayout>