【问题标题】:How to inflate a activity in my case?在我的情况下如何增加活动?
【发布时间】:2011-10-04 06:45:18
【问题描述】:

我想实现这个布局:

我的主要活动布局(ma​​in.xml);

(请鼠标右击下图查看图片)

我制作了另一个 ContentActivity(内容设置为 content_one.xml),它应该用作上述布局的一部分(右侧部分):

我知道我可以通过以下方式扩充布局:

LinearLayout mainLayout =  (LinearLayout) findViewById(R.id.main);

LayoutInflater inflater = (LayoutInflater)Home2.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View inflatedView = (View) inflater.inflate(R.layout.content_one, null);

mainLayout.addView(inflatedView);

我想知道,除了将 content_one 布局膨胀到主布局之外,是否可以在 android 中膨胀活动类而不是膨胀布局?如果可以,怎么做?

【问题讨论】:

    标签: android android-layout android-emulator android-widget android-manifest


    【解决方案1】:

    您不能像这样膨胀 Activity。考虑使用片段。

    http://developer.android.com/guide/topics/fundamentals/fragments.html

    【讨论】:

    猜你喜欢
    • 2019-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-22
    • 1970-01-01
    • 2013-04-30
    • 2010-11-06
    • 2012-10-29
    相关资源
    最近更新 更多