I would probably recommend not trying to change views within an activity.

While in theory it could be done it is not really the recommended way and
there have been multiple posts with people trying to do this and running
into multiple problems.  Most of them eventually end up switching to using
different activities and wasted a lot of development time trying to just
switch views within one activity.

It also tends to violate the really good programming practice of having
things do one thing, and one thing only...

That being said, there may be some cases where just switching views within
an activity would be acceptable and normal thing to do.  I haven't really
come across the need in my own programming efforts to do that.  An activity
should serve one purpose and one purpose only.  I guess an acceptable reason
to do that might be if you had multiple layouts for an activity that just
presented the same information to the user in a different way then that
would be ok.

It's all a matter of preference but the Android way is to use activities.
They have all sorts of options for controlling how they behave as well that
you can set in the manifest file.

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Fri, Jul 2, 2010 at 1:36 PM, Kostya Vasilyev <[email protected]> wrote:

> Tollas,
>
> First of all, there is Activity.finish(), which closes the activity.
>
> But if the way you want your app to interact with the user doesn't fit the
> way Activities are managed by Android, perhaps you can consider switching
> views inside an Activity?
>
> You can call setContent at any time to switch the layout, and obtain any
> necessary UI objects for the new view hierarchy (such as buttons, etc) - the
> stuff you normally do in onCreate(). Another option is to use a ViewFlipper,
> this way the entire layout with all of its variations can be loaded at once.
>
> Then you could handle the back key to return to previous layout or view (if
> using a ViewFlipper).
>
> This might be easier to implement than trying to bend Activities life
> cycle.
>
> -- Kostya
>
> 02.07.2010 23:19, Tollas пишет:
>
>  All activities are developed by me.
>> The NEW SEARCH button will be in all 3 activities.
>> B is launched from A. C is launched from B by the user (based on
>> button clicks).
>>
>> On Jul 2, 2:13 pm, Justin Anderson<[email protected]>  wrote:
>>
>>
>>> Are all three activities developed by you or are B&  C third-party
>>> activities?  In which Activity should this button reside?  Are B&  C
>>> launched from A or are they launched separately on their own by the user?
>>>
>>> ----------------------------------------------------------------------
>>> There are only 10 types of people in the world...
>>> Those who know binary and those who don't.
>>> ----------------------------------------------------------------------
>>>
>>> On Fri, Jul 2, 2010 at 1:06 PM, Tollas<[email protected]>  wrote:
>>>
>>>
>>>> I have 3 activities, activityA, activityB&  activityC.
>>>> I want to add a menu button NEW SEARCH that will destroy/finish all 3
>>>> and start a new activityA.
>>>> I do not want to finish the activities as they process as I want the
>>>> user to be able to navigate between the 3 unless the NEW SEARCH menu
>>>> option is chosen.
>>>>
>>>>
>>>
>>>
>>>> I guess basically I want to know how to finish activityB&  C from
>>>> activityA.
>>>>
>>>>
>>>
>>>
>>>> Thanks!
>>>>
>>>>
>>>
>>>
>>>> --
>>>> 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
>>>> [email protected]<android-beginners%[email protected]>
>>>> <android-beginners%[email protected]<android-beginners%[email protected]>
>>>> >
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/android-beginners?hl=en
>>>>
>>>>
>>>
>>
>
>
> --
> Kostya Vasilev -- WiFi Manager + pretty widget --
> http://kmansoft.wordpress.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
> [email protected]<android-beginners%[email protected]>
> 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
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to