Android Tutorial Different examples with 2 layouts

fabero

Member
Licensed User
Longtime User
Hi!

I use the TwoActivityLayouts example. I've an Activity and 2 layouts. Each layout had the horizontal and vertical variant.

But, If I'm vertical, and in second layout, when I rotate the phone to horizontal, Activity reload the first layout and don't remain to the second and use the horizontal variant..

How I can solve this?
 
Last edited:

dank

Member
Licensed User
Longtime User
Adding StateManager

Hi. I have an app with one activity and three layouts. It's based loosely on the SQL Example app. When the orientation changes, the first layout reappears with the selected row on my scrollview empty. If I have the second or third layout open, the reorientation also brings back the first layout. (Understandable since it goes through Activity_Create and _Resume again).

Is there a way to save the "data" on each layout and show the current one on an orientation change? Do I need to make each layout an activity instead? Any help will be appreciated!!
 

JaunLukePicard

Member
Licensed User
Longtime User
Relating to TwoPanelActivity

Klaus,

I downloaded and tried this example. I thought this would be close to what I was aiming for with a menu. Let me explain further,

I have an Activity that is an editor that loads a list of Stores. Once the list is loaded if I hit the Menu key on the device that a Layout file would be loaded which displays the menu choices. I decided to go this rout because I did not want to have way too many controls in the Designer. It can be hard to navigate.

So when you hit the Menu key the menu pops up and when you hit Back is disappears.

The stock popup menu doesn't seam to allow me to make the buttons appear on one line (i.e. Can I format them??)

I did see the library AHQuickAction, but that library didn't seam to be able to use buttons that I wanted unless I am missing something.

Any ideas? Thanks for the assistance...:sign0085:
 

JaunLukePicard

Member
Licensed User
Longtime User
A custom menu

Klaus,

I want to design a custom menu with the standard button Views. I thought I could use your twoPanelActivity to allow me to make a separate panel that I could add buttons to that I could invoke as needed.

I've seen examples where in the Designer I can hide a Panel, but the problem is that the views are still visible in the Designer cloging up what I see.

Does this help better explain what I am looking for?
 

klaus

Expert
Licensed User
Longtime User
Is the attached test program what you are looking for.
The program has a main layout (Designer).
A menu panel added by code to the main activity.
The content of the menu panel is a seperate layout (Designer).

Best regards.
 

Attachments

  • ManuPanel.zip
    7.5 KB · Views: 542

IslamQabel

Active Member
Licensed User
Longtime User
Dear Klaus:

Concerning Example Two Activity Layouts...( Main Activity, layout 1:TwoLayouts1,Layout2: TwoLayouts2)....when you move from the current layout to the second one....i see from code that you remove all views.....so this movement will cause loss of these views or not?...(In case of lose,do you need to add them again when you return to the first layout??? )

Thanks
 

klaus

Expert
Licensed User
Longtime User
..i see from code that you remove all views..
This is needed, because if you load a new layout it will be added to the previous one, if you don't want to show the previous layout you need to remove these views.
.so this movement will cause loss of these views or not?
Yes, if you want to display the first layout again you need to remove the current views and reload it.

The TwoActivityLayouts example is only to show the possibiliy.
It is not good practice to use this type of user interface.

You should either use :
- TwoLayoutActivities, this is the 'standard' way Android is designerd for. One activity for each layout.
- TwoPanelLayouts, this program uses two panels one for each layout and you manage the display by showing and hiding the panels.

Which one is better ?
There is no simple answer, it depends on the kind of program, the devices your target and what you want to show at the same time.
When Android ran only on smartphones the TwoLayoutActivities (multi-activities) method was the best .
Now with small and big screens (tablets) the TwoPanelLayouts (milti-panels) method can be useful because you can show two panels at the same time on tablets in landscape and one panel at the same time on the phones in portrait, this would be difficult to manage with different ativities. That's what I did in one of my latest project.
 

IslamQabel

Active Member
Licensed User
Longtime User
Dear Klaus....Thanks a lot for your reply.....Actually i will tell you about some issues:
  • My program is consist of two activities ("Main" with layout called "1" ,"activity2" with layout called "2")....I added ImageView objects in layout 1 and then load images for each object from my mobile...Then by click on a button ....these images are transferred to layout "2" ....the problem is i want to add more images in layout "1" but it is not enough to add more so i was thinking by sliding or by adding another layout....so How to do that?
  • This is important question....i would like to help me to know the Answer.....The philosophy of designing a program... if i want to buy my program in Google play for example, i must design my app to be compatible with all API levels.....and to do that.....should i make the target for the highest API level or what to do??? as well as screens of devices......
 

IslamQabel

Active Member
Licensed User
Longtime User
A question please....
Can i add ImageView object by designer to each layout related to each panel or it need a code???
 

klaus

Expert
Licensed User
Longtime User

IslamQabel

Active Member
Licensed User
Longtime User
Thanks for reply...
I want to add more objects in the layout related to Main activity.........for example i can put 10 images....if i want to add 30 images in the same layout, the layout will not enough to put them by designer ....understand me?? The user can slide the layout or click to show the the other images....
Understand me?
 

IslamQabel

Active Member
Licensed User
Longtime User
add them not in the program is running....just i want to set fixed number of images say.....30 or 40
 

IslamQabel

Active Member
Licensed User
Longtime User
For the Flicker example,....the shown images are nine ....if i want to 20 or 30 ...in code i can declare more images Dim imageview10 as Imageview......till Dim ImageView40 As ImageView..... ..but how to show them on the screen when the programm is ruuning..?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…