ViewFlipper Issue

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

ViewFlipper Issue

Postby matany » Sun Dec 13, 2009 9:29 pm

Hi,

I know this is simple, but now I don't the the answer. Please help.

I have...

1 Activity
3 xml layouts. (layout1, layout2, layout3)

I am working with ViewFlipper flipper. I am trying to do the following...

- Initially, I show layout1 fine (one button1 onclick, flipper.next() go to layout2), (works fine for me)
- Once you are in layout2, I have (one button2 onclick, flipper.next() go to layout3), (works fine for me)

The problem is, when I come to layout3, I have one button3 and I would like to click that button and go back to...layout1.

Is this possible?

This is taking me few days.

Thanks a lot.

Y
matany
Experienced Developer
Experienced Developer
 
Posts: 66
Joined: Tue Dec 08, 2009 9:29 pm

Top

Postby matany » Sun Dec 13, 2009 10:07 pm

I got it...As I said it was very simple, I just had my logic wrong.

The solution is...

flipper.setDisplayedChild(R.layout.your_layout_file_you_want_to_display);

Y
matany
Experienced Developer
Experienced Developer
 
Posts: 66
Joined: Tue Dec 08, 2009 9:29 pm

Postby Droid123 » Mon Dec 14, 2009 1:21 am

could you explain what a viewflipper is and does?
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Postby matany » Mon Dec 14, 2009 2:44 am

Hi,

ViewFlipper is a neat way to display various layouts in your app. Instead of creating many activities to display several layouts and using intents (performance issues), you could create one main.xml and use include tag in main.xml to import several xml files that way.

This is useful if you are designing an app that has many screens...

Y
matany
Experienced Developer
Experienced Developer
 
Posts: 66
Joined: Tue Dec 08, 2009 9:29 pm

Postby Droid123 » Mon Dec 14, 2009 4:13 am

matany wrote:Hi,

ViewFlipper is a neat way to display various layouts in your app. Instead of creating many activities to display several layouts and using intents (performance issues), you could create one main.xml and use include tag in main.xml to import several xml files that way.

This is useful if you are designing an app that has many screens...

Y


Thanks for your explanation.

But how does this affect the backstack? Because technically, these layouts will be inflation within the same activity, so there won't be anything to go back to
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Postby matany » Mon Dec 14, 2009 4:19 am

What do you mean there won't be anything to go back to...?

You can navigate to which ever layout you want at any given time in one activity.

Y
matany
Experienced Developer
Experienced Developer
 
Posts: 66
Joined: Tue Dec 08, 2009 9:29 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests