Android的:如何两种观点添加到一个活动 [英] Android: How to add two views to one activity

查看:112
本文介绍了Android的:如何两种观点添加到一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,我想补充两个视图中的一个活动,像

I have a program where I want to add two views in one activity, like

 public class AnimationActivity extends Activity {
 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(new GraphicsViewForBitmap(this));
        setContentView(new GraphicsView(this));


    }
}

在这里GraphicsViewForBitmap&放大器; GraphicsView两类延伸视图。
所以我想在同一时间两个视图应该设置为一个活动。
可能吗?
PLZ给我答案。
谢谢

where GraphicsViewForBitmap & GraphicsView are two classes extends view. so I want at a time two views should set to an activity. Is it possible? Plz give me answer. Thanks

推荐答案

是的,但首先你必须把他们的ViewGroup内,例如一个的LinearLayout,然后设置使用的ViewGroup的setContentView。由于与现有的code你不只是附加与第一第二种观点,但你正在设置另一个内容。

Yes but first you have to put them inside a ViewGroup, for example a LinearLayout, and then set that ViewGroup with setContentView. Because with the existing code you're not just appending the second view with the first, but you are setting another content.

这篇关于Android的:如何两种观点添加到一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆