我想实现这个布局:
我的主要 Activity 布局(main.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 中膨胀 Activity 类而不是膨胀布局?如果可以,怎么做?
最佳答案
你不能这样膨胀一个 Activity 。考虑使用 fragment 。
http://developer.android.com/guide/topics/fundamentals/fragments.html
关于android - 在我的案例中如何膨胀 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6675747/