user111823
user111823

Reputation:

Replace tab with another view

I have a TabActivity with a tab, which shows a list. I'd like to display a WebView whenever a list item is clicked. I tried calling listSpec.setContent(R.id.details); but it would not find the resource.

Any clues what I am doing wrong?

UPDATE: I found the following clue from Mark in the mailing list

You don't change the View inside of a tab. You cause the existing View to show something else (e.g., use FrameLayout and make one layer VISIBLE and another layer GONE, or use ViewFlipper to swap between contents).

You might be able to get setContent() to replace the current View by passing in another layout ID or TabContentFactory, but I'm skeptical this will work.

The tab widget framework in Android is designed for simple stuff. You may wish to grab the source code for the relevant classes out of Android and make your own version that handles your own scenario.

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

Upvotes: 0

Views: 698

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006644

I don't know if I'd trust the guy you got your update from. He's...he's...he's...he's balding!

;-)

The most common pattern on Android is for clicking a list item to bring up another activity. If for some reason you don't want that, then the advice I gave in your update is still valid -- you can achieve your effect by hiding the ListView and showing the WebView by one means or another.

Upvotes: 1

Related Questions