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. No Network Connectivity in Service/AlarmManager Process.



That looks strange.

-- WifiLock is managed by WifiManager, which is not a PowerManager.

-- WifiManager has a createWifiLock() method to create the WifiLock, not
a newWakeLock() method

Also, I'm not sure this is necessarily going to work if you are locking
and unlocking at the time you are doing the WakeLocks. If your goal is
for WiFi to be available immediately upon the alarm, you will need to
use a WifiLock to keep WiFi active back when you schedule the alarm. To
quote from the WifiLock documentation:

"Normally the Wi-Fi radio may turn off when the user has not used the
device in a while. Acquiring a WifiLock will keep the radio on until the
lock is released. Multiple applications may hold WifiLocks, and the
radio will only be allowed to turn off when no WifiLocks are held in any
application."

If this is something that's supposed to be going on 24x7, since keeping
the WiFi radio on all that time will drain the battery pretty good, I
think you're more going to need to just hang tight in your
doWakefulWork() until WiFi connectivity is restored.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in NYC: 10-11 April 2010: http://guruloft.com

-- 

2. No Network Connectivity in Service/AlarmManager Process.



Cellular data should be always on, if I understand correctly.


Bzzzzt.


Ding, ding, ding!

:-)


IntentService in general is not designed for you to fork other threads.
Remember: the IntentService component will call stopSelf() as soon as
onHandleIntent() returns, if there is no other Intent queued up to be
processed.

Since IntentService does its work (onHandleIntent()) in a background
thread, I don't know why you're forking yet another thread. I'd just do
the HTTP operations in doWakefulWork().

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

-- 

3. PCM format

4. Gallery android:unselectedAlpha works strangely

5. Problem seen in run Android (eclair) on an SMDK6410

6. I wonder can i eliminate android Indicator bar shadow effect or not?

7. Alarm