I am trying to create a small Android App. The app will have four modes. The top part of the display will contain four buttons to switch between these modes, and this part of the display will not change. The rest of the display will change depending which button has been clicked on. It will contain a table with TextViews or images.
My questions are:
-
Is it possible to create the table layout programmatically?
-
How should I approach switching between modes:-
- Four separate
Activityclasses? - One
Activityand programmatically change the bottom part of it? - Should I create one base
Activitywith buttons and extend it?
- Four separate
What would be the best option?
Create layout by code is not the good solution. If your table layout is simple, I think it’s not a big problem.
Here is a simple code how to create a layout by code :
And as you see, it looks ugly !
Hope this help 🙂
@: Edit for additional question about Relative Layout:
In
RelativeLayout(and some Layout of android), there is an objectLayoutParamsto determine some properties of sub-layout (TextView, Button… is called sub-layout too if you put in other Layout)Here is an example :
You should notice
BELOW, it is one of many int constant such asRight_of…. You can see on Android Document about these.