simple layout design question

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

simple layout design question

Postby whitecloud » Wed Feb 17, 2010 12:17 am

Hi guys,

I have two screen to show, one screen to show some text, the other screen to show a chart, both screens have same buttons: textShowButton and chartShowButton. When application start, it will show text screen autamatically. When chartShowButton is clicked, the chart screen needed to be shown which will need some para from text screen. Text screen could be shown by clicking the textShowButton.

My question is that should I have two activity corresponding two screen? Like making text screen as main activity, when chartShowButton is clicked, initiate chart screen activity, in such case, how could I new the activity, is it like to new a normal java class?

The other solution I have in mind is only have one activity, one screen with two buttons on bottom, but with textShow and chartShow changed dynamically when corresponding button is clicked? Is this method applicable? Could I use layout to add/remove textShow/chartShow which are part of the layout?

Or other better solution?

Thanks a lot for the help.
whitecloud
Freshman
Freshman
 
Posts: 5
Joined: Thu Feb 11, 2010 10:13 pm

Top

Re: simple layout design question

Postby pmws » Wed Feb 17, 2010 9:02 am

whitecloud wrote:Hi guys,
My question is that should I have two activity corresponding two screen? Like making text screen as main activity, when chartShowButton is clicked, initiate chart screen activity, in such case, how could I new the activity, is it like to new a normal java class?

The other solution I have in mind is only have one activity, one screen with two buttons on bottom, but with textShow and chartShow changed dynamically when corresponding button is clicked? Is this method applicable? Could I use layout to add/remove textShow/chartShow which are part of the layout?

Or other better solution?

Thanks a lot for the help.


I think both ways are applicable. I would try the second one with something like this:

Have the ShowText and the ShowChart View in the same XML Layout (on the same spot).
Add a visibility attribute to the one thas not initinaly showing. Set it to "gone"
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:visibility="gone"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Get a handle for both views.
If the button is pressed :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. showText.setVisibility(View.GONE);
  2. showChart.setVisibility(View.VISIBLE);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Im not a 100% sure if this will do the job, but this is how I would start. Let me know if it worked.




When the Button is pressed
pmws
Developer
Developer
 
Posts: 37
Joined: Thu Sep 24, 2009 12:23 pm

Postby whitecloud » Wed Feb 17, 2010 5:07 pm

Thank you pmws for the help! I will try your recommendation and let you know it.
whitecloud
Freshman
Freshman
 
Posts: 5
Joined: Thu Feb 11, 2010 10:13 pm

Postby whitecloud » Thu Feb 18, 2010 4:06 pm

It works. Thank you pmws again for the help.
whitecloud
Freshman
Freshman
 
Posts: 5
Joined: Thu Feb 11, 2010 10:13 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests