8
我想包括以下布局两次:机器人 - XML - 包括相同布局的多次不起作用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<com.viewpagerindicator.TabPageIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
像下面
<include
android:id="@+id/include1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/view_pager" />
<include
android:id="@+id/include2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/view_pager" />
实际上,第二个视图寻呼机不工作,如果我这样做...第二个视图寻呼机始终保持空...如果我复制我的view_pager布局,并更改此布局中的id(寻呼机到pager2和指标到indicator2)e一切都很好。有没有更好的方法来做到这一点?复制布局实现,似乎使包括多个包括无用的包括相同的布局...
我得到正确的引用我认为,但它只是不起作用,如果我包括相同的布局。 ..
pager1= (ViewPager)(findViewById(R.id.include1).findViewById(R.id.pager));
pager2= (ViewPager)(findViewById(R.id.include2).findViewById(R.id.pager));
一切完美,如果我复制布局...
编辑:
我认为它与FragmentManager做,因为视图寻呼机有相同的ID ...但我不知道如何正确解决...