Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old December 24th, 2012, 05:14 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2012
Posts: 6
 
Device(s):
Carrier: Not Provided

Thanks: 2
Thanked 0 Times in 0 Posts
Default Create a new Activity or update view of existing activity?

I am very new to android development. I am working on developing an app and I am not sure when should I use a new activity and when should I update the existing view.

For example, lets say I have a view that shows a multiple choice question.Now, when the user selects his choices and clicks on say "Evaluate", I want to show the same question view but along with the right answers and explanations for each option. So does that mean, I should send an Intent upon a click on Evaluate or I should just update the view (i am not sure how)?

If I send an intent and show a new screen, how can the user go back to the next question without displaying the answers?
If I don't create an new activity, how can I update the existing view that is already displayed?

I guess I am just confused about the flow. Please pardon me if my question doesn't make any sense.

thanks!

andypaul1 is offline  
Reply With Quote
sponsored links
Old December 24th, 2012, 10:30 PM   #2 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

For your example, it would be best to use the same Activity, but just update the content of the Activity's Views.

Activities can generally be thought of as windows in a traditional window manager. They should be used to separate logical steps in an application's use.
__________________
My blog, Inverted Keystrokes, is looking for aspiring developers (not necessarily with Android) to post articles. If you have any development experience and are interested in participating, please PM me. =)
jonbonazza is offline  
Reply With Quote
The Following User Says Thank You to jonbonazza For This Useful Post:
andypaul1 (December 25th, 2012)
Old December 25th, 2012, 02:25 PM   #3 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2012
Posts: 6
 
Device(s):
Carrier: Not Provided

Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thank you for your suggestion, jon.
Any pointers on how to update an existing view that is already being displayed? I come from Java Swing world where I can simply add/remove components from a container in the event thread and the view is updated automatically. Or I just update the model (such as for a JTable) and call fireTableDataChanged, which updates the view.

How does this work in Android app? As I understand the view is described in a hardcoded XML file, so how do I update it dynamically?

thank you!
andypaul1 is offline  
Reply With Quote
Old December 25th, 2012, 04:22 PM   #4 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

You can really do the same thing in Android, but it is better practice to create all of the UIs up front and either show/hide various controls depending on the state, or simply create your layouts in seperate xml files and use the setContentView() method to swap between them.
jonbonazza is offline  
Reply With Quote
The Following User Says Thank You to jonbonazza For This Useful Post:
andypaul1 (December 25th, 2012)
Old December 25th, 2012, 06:04 PM   #5 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2012
Posts: 6
 
Device(s):
Carrier: Not Provided

Thanks: 2
Thanked 0 Times in 0 Posts
Default

ok, thank you again.
andypaul1 is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:46 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.