-
Notifications
You must be signed in to change notification settings - Fork 0
How to use BaseClass
Klaus Schmidt edited this page Nov 20, 2019
·
2 revisions
Hey guys, I just implemented the base class with which we're able to display a footer and use an improved toolbar. We just have to extend all our activities with this class.
- Usually we extend all our classes with AppCompatActivity. Replace this with BaseActivity (which is already extended by AppCompatActivity).
- BaseActivity is an abstract class. You have to implement getLayoutID and getLayoutTitleDescriptor. getLayoutID has to return the R.layout.youractivitylayout. getLayoutTitleDescriptor has to return the R.string.youactivitytitle.
- Remove everything from onCreate which inflates the graphic layout (e.g. setContentView). This is done by the BaseClass already.
- If u used the "parentClass" setting in the manifest before, just remove it.
Here you can see a very basic implementation. All your buttons and whatever else you wanna do, has to be done in onCreate as always.
package innolab.pallicare;
import android.os.Bundle;
import innolab.pallicare.ui.BaseActivity;
public class QuestionnaireActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected int getLayoutID() {
return R.layout.activity_questionnaire;
}
@Override
protected int getLayoutTitleDescriptor() {
return R.string.questionnaire_activity_title;
}
}
Link to snippet: https://mad-srv.informatik.uni-erlangen.de/InnoLab/ws19-20/palliative-care/snippets/14