【发布时间】:2015-07-01 13:41:32
【问题描述】:
我正在尝试在另一个布局中膨胀一个布局,但它不起作用... 在我的活动中,我显示了黑色的 activity_serie.xml,然后我尝试在白色的 image_item.xml 上充气。但我从未见过 image_item.xml。
public class Serie extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_serie);
ViewPager mainLayout = (ViewPager) findViewById(R.id.serie_pager);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View menuLayout = inflater.inflate(R.layout.image_item, mainLayout, true);
}
@Override
protected void onResume() {
super.onResume();
}}
activity_serie.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/serie_pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
image_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
谁能告诉我为什么? 谢谢。
【问题讨论】:
-
你应该为你的图像视图设置一些东西吗?
-
我已经删除了,我也有同样的行为
标签: android xml layout android-inflate