Do i need to make new side menu for every activity?
izikda opened this issue · 1 comments
izikda commented
or there is another way to do one menu for all activities?
dmitry-zaitsev commented
You have plenty of options.
Most common case is to use Fragments. So, you'll swap Fragments while using single Activity (and as a result - single layout).
Another way (not so simple and not so elegant) - create some base xml layout (with side menu) and base Activity class. So, you'll have something like that:
public BaseActivity extends Activity {
private ViewGroup mContainer;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.base_xml); //"super" is important here
mContainer = (ViewGroup) findViewById(R.id.mainContainer); //here is id of container of your main layout inside side menu. Just some FrameLayout, for example.
}
@Override
public void setContentView(int id) {
/* Here is where magic comes */
LayoutInflater inflater = LayoutInflater.fromContext(this);
inflater.inflate(id, mContainer);
}
}