You are treading on the outer bounds of the SDK, and in general embedded activities is a rough area that has many limitations and quirks. As a general rule you should rely on ActivityGroup and LocalActivityManager as the basic pieces of the framework to use, and then you'll need to look at what TabActivity etc. do on top of that to figure out what you need to do to have the same behavior. Sorry, I don't have any handy answers to give you, you're going to need to figure out most of this from the existing code.
On Tue, Feb 10, 2009 at 2:06 PM, kingkung <[email protected]> wrote: > > I have been looking at the source code. I'm looking in particular at > TabActivity/TabHost/TabWidget and how it works. I'm looking at > setCurrentTab() in TabHost, which from my experience is sufficient in > "closing" an activity, and trying to understand everything that's > going on. Notes below. > > I need to understand better how localActivityManager fits into the > code. > > public void setCurrentTab(int index) { > if (index < 0 || index >= mTabSpecs.size()) { > return; > } > if (index == mCurrentTab) { > return; > } > > // using the IntentContentStrategy, this merely sets the view > visibility to View.GONE > if (mCurrentTab != -1) { > mTabSpecs.get(mCurrentTab).mContentStrategy.tabClosed(); > } > > //set focus on the current tab > mCurrentTab = index; > final TabHost.TabSpec spec = mTabSpecs.get(index); > mTabWidget.focusCurrentTab(mCurrentTab); > > // getContentView() starts the activity if null, and sets the > view to visible > mCurrentView = spec.mContentStrategy.getContentView(); > > if (mCurrentView.getParent() == null) { > mTabContent > .addView( > mCurrentView, > new ViewGroup.LayoutParams( > > ViewGroup.LayoutParams.FILL_PARENT, > > ViewGroup.LayoutParams.FILL_PARENT)); > } > > if (!mTabWidget.hasFocus()) { > mCurrentView.requestFocus(); > } > invokeOnTabChangeListener(); > } > > *** > > I commented on the code that I have traced through. From what I see, > setCurrentTab() will change the previous window's view to View.GONE, > and the current view to View.VISIBLE. I've tried this in my > ActivityGroup code and it's not surprisingly not enough. > > If someone can point me more specifically to where the activity is > actually "disabled" within this code (or where the > localActivityManager is called), that would help me tremendously. > > Or, if someone could show me a way in which tabs can be made > unselectable/unscrollable in a TabActivity, that would help out > equally. The fact that I was always able to switch tabs with the > trackball, even when TabWidget's selectable and focusable values are > false, is the entire reason why I am using ActivityGroup instead. > > > On Feb 10, 1:50 pm, "Justin (Google Employee)" <[email protected]> > wrote: > > The answer is that its complicated. You need to switch not only the > > View, but the entity that the system considers to be active. As Dianne > > suggests android.app.LocalActivityManager is where I'd start, > http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;... > > . A lot of the heavy lifting is done here, but there's also > > android.widget.TabHost and android.app.ActivityGroup (which TabHost > > extends), and android.app.ActivityThread. > > > > Cheers, > > Justin > > Android Team @ Google > > > > On Feb 10, 1:36 pm, Dianne Hackborn <[email protected]> wrote: > > > > > Well it doesn't use a ViewFlipper. :} I suggest looking at the code. > > > > > On Tue, Feb 10, 2009 at 11:43 AM, kingkung <[email protected]> > wrote: > > > > > > I'm trying to implement my own ActivityGroup to mimic TabActivity > > > > (without tabs) but I'm having trouble "closing" activities. My > > > > ActivityGroup has a ViewFlipper, each housing a separate activity's > > > > window. When I attempt to switch "activities" I call > > > > ViewFlipper.setDisplayedChild() on the view of choice. > > > > > > However, when I scroll up and down in the view of choice, the OTHER > > > > non-visible activities' views are responding to these actions, so it > > > > seems like I'm not successfully "switching" the activity fully. > > > > > > When I use a TabActivity to run this code, this doesn't happen; when > I > > > > scroll up and down in one activity, I don't see any event firing from > > > > any of the other activities. > > > > > > I'm wondering... what does TabActivity do to handle these activities > > > > as separate, individual entities? > > > > > -- > > > Dianne Hackborn > > > Android framework engineer > > > [email protected] > > > > > Note: please don't send private questions to me, as I don't have time > to > > > provide private support. All such questions should be posted on public > > > forums, where I and others can see and answer them. > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

