开发者

Opening an activity within a View in Android

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 define开发者_开发百科d 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!


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜