0

I've recently started developing Android Apps, and whilst the model is making more sense the more I look at it, I cannot do something (nor find any reference material on it) which to me seems quite simple.

I have an activity which has five buttons along the bottom, and a blank View taking up the rest of the screen. I want, upon clicking these buttons, for an activity to be opened in (and confined to) this view. I can get a new activity running without incident, but this opens in a new screen.

If anyone can show me an easy way to launch a (sub/child?) activity within a view which is defined in the parent activity's layout xml file - equally, it could be created in the parent activity - you'd really be doing me a favor!

Cristian
  • 198,401
  • 62
  • 356
  • 264

2 Answers2

0

You can achieve that by using an ActivityGroup... here is a simple example which shows how to do it using a TabActivity:

http://web.archive.org/web/20100816175634/http://blog.henriklarsentoft.com/2010/07/android-tabactivity-nested-activities/

Of course, you will have to change the code since you are not using TabActivities. Just take a look at the getLocalActivityManager and getDecorView methods that is what you will be using.

miguel
  • 73
  • 1
  • 2
  • 7
Cristian
  • 198,401
  • 62
  • 356
  • 264
0

I'd recommend taking a look at TabHost. The tabhost is an Activity itself, and the sub-views are all Actvities as well.

Here is a good tutorial that'll get you going very quickly. There is a more work to create (optional) icons for the tabs (also describe in the tutorial).

Hope this helps.

Edit* You mentioned buttons being at the bottom of the screen. Take a look at this SO Question

Community
  • 1
  • 1
pjama
  • 3,014
  • 3
  • 26
  • 27