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. 'system.out.println' dumpage



It goes nowhere. Don't use it. Use android.utils.Log for all your
logging needs, which will be available in logcat.

R/

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

2. Please GoogleDevTeam, work on Android Exchange Support

i read the official reply on CNet and had my dreams crushed

http://news.cnet.com/8301-17938_105-10241394-1.html?tag=mncol;title

"Android does not currently include support for Microsoft Exchange.
This remains a ripe opportunity for 3rd parties, as the Android Open
Source project, supported by Android Market, provides developers
complete freedom to extend Android and enable a wide range of
connected mobile services."

you don't understand, no one corporate is going to search your
arguably horrific app market to find a 3rd party knockoff brand
application to install on all their corporate phones to get exchange
to run.

when companies go to shop for phones they're going to look at OFFICIAL
support and see "hey this one doesn't have native exchange support,
sorry lads back to your blackberries"

you will NEVER gain a foothold in the very large and lucrative
enterprise market if you don't support commonly accepted enterprise
applications "out of the box".  and to be honest you do your loyal
developer base a huge disservice by denying them traction in this
market.

android deserves it

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

3. HTC Magic - Can't install driver on development PCs

4. error (or out-of-date info) in docs

5. Bug in WebView highlight (and workaround)

6. Help with porting onto i900.

7. How to add more words onto Binary Dictionary(main.dict)??