Hi,,

U can have the one activity with 2 views. For that you need to set the new
layout (say view 2) using setContentView() function when button 1 is pressed
in view 1. When user press the BACK key, handle the same using onKeyDown()
and call again setContentView() method with view1 layout.

But problem with above approach will be when u rotate the screen then it
will call OnCreate() of activity which will again set the view 1 content if
view 2 has been set previously.

So it is better to have 2 activity rather trying to draw the 2 views in 1
activity.



On Mon, Jun 14, 2010 at 6:09 PM, Steven Maitlall <m.ste...@gmail.com> wrote:

> You should really be using Intents to launch activities, like Justin said.
> Each of your views would be a separate activity. The OS will handle going
> back to the previous activity for you, by means of the phone's back button.
> When a button is clicked that should switch to a different view, launch an
> Intent. Android will handle the rest.
>
>
> On Sun, Jun 13, 2010 at 6:05 AM, Ubuntu Explorer <ubuntuexplo...@gmail.com
> > wrote:
>
>> Hi,
>>
>> I would like to switch between two views.
>>
>> View 1 - button 1 -> View 2.
>> View 2- Back -> View 1.
>>
>> Regards,
>> UE.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Beginners" group.
>>
>> NEW! Try asking and tagging your question on Stack Overflow at
>> http://stackoverflow.com/questions/tagged/android
>>
>> To unsubscribe from this group, send email to
>> android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com>
>> For more options, visit this group at
>> http://groups.google.com/group/android-beginners?hl=en
>>
>
>
>
> --
> Steven
> Maraj
> http://www.marajservices.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to