Switching Of Screens

by Rachna » Wed, 25 Jun 2008 19:17:32 GMT


Sponsored Links
 Hello Friends

When i started making an application in android i designed two
screens.....
1.termsscreen.xml
2.loginscreen.xml
in res/layout.
Then i made every java file in my package extending Activity....
I mean i made two java classes:-
1.TermsScreen.java extends Activity
2.LoginScreen.java extends Activity
And then to switch between these two i used INTENT and it worked out.

*Important

But now i want to change my code...
I want that there should be only one class that extends Activity(say
main_activity).
And then i want the two classes TermsScreen.java and LoginScreen.java
should get reference of that main_activity class.

I wrote code for all this and again made use of INTENT for switching
but its not working.
Can anyone please tell me will INTENT work or should i use something
else to go from TermsScreen.java to LoginScreen.java

Thanks in advance

--~--~---------~--~----~------------~-------~--~----~



Switching Of Screens

by Mark Murphy » Wed, 25 Jun 2008 19:42:26 GMT


 > But now i want to change my code...

Intents are for switching between activities (among other uses), not for
changing the UI of a single activity.

You can try calling setContentView() to the new UI when it is time to
switch, but I am not certain that will work.

What will work is to use ViewFlipper or another concrete ViewGroup
subclass. These work like tabbed windows (i.e., multiple discrete
"screens"), just without the actual tabs -- you are responsible for
switching between them as needed. It will require some reworking of your
code, such as perhaps combining the two layout XML files into one.

The Animation2.java sample in the ApiDemos with the SDK uses ViewFlipper.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ -- Available Now!


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Open Source Group...

Google,

if you watch this video:

http://www.ted.com/talks/clay_shirky_how_cognitive_surplus_will_change_the_world.html

you (?) will realize how beneficial it will be to set up a discussion group for 
just open source application development.

-- 

2. fancy widget

rr, apa ada yg pake fancy widget? apa ada yg alami utk forcast weather-nya
tdk bisa update slma be2rpa hr ini ya? apa krn ada efek sdh dihentikan krn
mirip ama htc sense??

-- 
"Indonesian Android Community [id-android]" 

3. How to change ClassLoader of Activity

4. Placing focusable & clickable views in a custom expanded view in the notification bar

5. Mod: Invitation, Bada Developer Day

6. Paging HTC Tattoo user

7. ContentProvider onCreate() onDestroy()