android - 在我的案例中如何膨胀 Activity ?

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

我想实现这个布局:

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

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

enter image description here

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

enter image description here

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

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/

相关文章:

android - 字符串资源中的土耳其语字符

android - 2 个视频 1 个媒体 Controller

android - Volley android 库发布请求不起作用

android - Material Complex UI with Coordinate layout + Tablayout + Viewpager +recyclerview

java - 屏幕密度高的设备上的大元素

Android Phone EditText 未更新设备上的显示

android - 如何在安卓模拟器中为印度地方语言设置自定义语言环境

android - 如何在 android 中通过电子邮件 Intent 从 sd 卡发送 .apk 文件?

android - PRODUCT_ID/SenderID 是否只是 Google Cloud Messaging 中的唯一标识符

安卓模拟器颠倒