Extending Another Class And Inflating Its Xml In My Current Activity Hides The Content Of My Current Activity
I have created a navigationactivity where i am having navigation drawer and now when i extend this class in another activities its working but the content of other actvities are no
Solution 1:
I think you are searching for the hierarchy used in the concept of BaseActivity
you can make many child and use the behavior of parent. The formal concept is pass the layout from child Activity to the BaseActivity
and BaseActivity
will set the content.
First create an abstract class and name it BaseActivity
, It should be something like
publicabstractclassBaseActivityextendsAppCompatActivity{
@OverridepublicvoidonCreate(bundle) {
super.onCreate(bundle);
setContentView(getLayoutResourceId());
}
protectedabstractintgetLayoutResourceId();
}
Then in your case extend BaseActivity
in NavigationActivity
like here
publicclassNavigationActivityextendsBaseActivity {
@OverridepublicvoidonCreate(bundle) {
super.onCreate(bundle);
// do extra stuff on your resources, using findViewById on your activity_navigation
}
@OverrideprotectedintgetLayoutResourceId() {
return R.layout.activity_navigation;
}
}
Post a Comment for "Extending Another Class And Inflating Its Xml In My Current Activity Hides The Content Of My Current Activity"