Last Updated: September 27, 2021
·
1.53K
· outlying

Android, simple Activity templates

Lets assume that you need Activity with bottom menu present at all sreens ( iPhone style ). Create BottomMenuActivity class, descendant of Activity class. Override onCreate:

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    super.setContentView(R.layout.a_bottommenu);

    // ... do the rest ...
}

Then you may simply override setContentView method, so it will look like this:

@Override
public void setContentView( int layoutResID ){

    // container is a part of a_bottommenu.xml layout
    FrameLayout container = (FrameLayout) 
            findViewById( R.id.containerBottomMenu );

    getLayoutInflater().inflate( layoutResID, container, true );
}

Now you may subclass BottomMenuActivity and when you will call setContentView you will fill free space inside a_bottommenu.xml

1 Response
Add your response

@kubamor It would be nice to comment in english. May I ask how is this related to tip ?

over 1 year ago ·