У меня есть один макет, который включает в себя четыре разных вида, обернутых в вертикальный линейный макет, и вид в виде пейджера в отдельном макете, но видоискатель ничего не отображает, когда я пытаюсь накачать один макет в пейджер с помощью адаптера пейджера, но представления хорошо заполняются на recyclerView;
Вот мой файл single_layout. xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<EditText
android:id="@+id/milestone_layout_edit_describe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.7"
android:backgroundTint="@android:color/transparent"
android:fontFamily="@font/rokkitt_regular"
android:hint="describe this milestone"
android:inputType="text"
android:textColor="@color/black"
android:textSize="16sp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="-7dp"
android:background="@color/middi_blue" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.7"
android:fontFamily="@font/rokkitt_regular"
android:text="start date"
android:textColor="@color/black"
android:textSize="16sp" />
<EditText
android:id="@+id/milestone_layout_edit_start_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:alpha="0.5"
android:backgroundTint="@android:color/transparent"
android:enabled="false"
android:focusable="false"
android:fontFamily="@font/rokkitt_regular"
android:hint="DD-MM-YY"
android:inputType="date"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/milestone_layout_edit_start_date_layout_linear"
android:layout_width="match_parent"
android:layout_height="42dp"
android:orientation="horizontal" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="-7dp"
android:background="@color/middi_blue" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.7"
android:fontFamily="@font/rokkitt_regular"
android:text="end date"
android:textColor="@color/black"
android:textSize="16sp" />
<EditText
android:id="@+id/milestone_layout_edit_end_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:alpha="0.5"
android:backgroundTint="@android:color/transparent"
android:enabled="false"
android:focusable="false"
android:fontFamily="@font/rokkitt_regular"
android:hint="DD-MM-YY"
android:inputType="date"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/milestone_layout_edit_end_date_layout_linear"
android:layout_width="match_parent"
android:layout_height="42dp"
android:orientation="horizontal" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="-7dp"
android:background="@color/middi_blue" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.7"
android:fontFamily="@font/rokkitt_regular"
android:text="NGN"
android:textColor="@color/black"
android:textSize="16sp" />
<EditText
android:id="@+id/milestone_layout_edit_ngn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="48dp"
android:alpha="0.5"
android:backgroundTint="@android:color/transparent"
android:fontFamily="@font/rokkitt_regular"
android:hint="14,999.55"
android:inputType="number"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="-7dp"
android:background="@color/middi_blue" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:alpha="0.6"
android:fontFamily="@font/rokkitt_regular"
android:text="BALANCE REMAINING"
android:textColor="@color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/milestone_layout_text_remaining_balance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:layout_marginBottom="18dp"
android:fontFamily="@font/rokkitt_regular"
android:text="NGN 20,000.00"
android:textColor="@color/black"
android:textSize="17sp" />
</LinearLayout>
</RelativeLayout>````
My PagerAdapter class:
```public MilesPagerAdapter(Context context, int count, MilesView milesView) {
this.context = context;
this.count = count;
this.milesView = milesView;
}
@Override
public int getCount() {
return count;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, final int position) {
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.milestones_layout, container, false);
editDesc = view.findViewById(R.id.milestone_layout_edit_describe);
editStartDate = view.findViewById(R.id.milestone_layout_edit_start_date);
editEndDate = view.findViewById(R.id.milestone_layout_edit_end_date);
textBal = view.findViewById(R.id.milestone_layout_text_remaining_balance);
editNgn = view.findViewById(R.id.milestone_layout_edit_ngn);
editStartDateLinear = view.findViewById(R.id.milestone_layout_edit_start_date_layout_linear);
editEndDateLinear = view.findViewById(R.id.milestone_layout_edit_end_date_layout_linear);
Toast.makeText(context, "added "+position, Toast.LENGTH_SHORT).show();
container.addView(view);
return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((View) object);
}
}```
My ViewPager layout :
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/receiver_buyer_deal_payment_milestone_number_of_milestones_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.05"
android:background="#545454" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageButton
android:id="@+id/receiver_buyer_deal_milestones_add_more_milestones"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="end"
android:layout_marginTop="18dp"
android:layout_marginEnd="59dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_vector_22"
android:visibility="gone" />
<ImageButton
android:id="@+id/receiver_buyer_deal_delete_milestones_btn"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="end"
android:layout_marginTop="15dp"
android:layout_marginEnd="59dp"
android:background="@android:color/transparent"
android:src="@drawable/delete_can_red" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal">
<View
android:layout_width="5dp"
android:layout_height="56dp"
android:layout_alignParentStart="true"
android:background="#58C284" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginStart="36dp"
android:layout_marginEnd="36dp">
<ImageView
android:id="@+id/receiver_buyer_deal_milestone_showw_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:rotation="180"
android:src="@drawable/ic_vector_25"
android:visibility="invisible" />
<TextView
android:id="@+id/receiver_buyer_deal_milestone_text_counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:fontFamily="@font/rokkitt_regular"
android:text="MILESTONE 1"
android:textColor="@color/black"
android:textSize="16sp" />
<ImageView
android:id="@+id/receiver_buyer_deal_milestone_show_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="26dp"
android:src="@drawable/ic_vector_25" />
</RelativeLayout>
</RelativeLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/receiver_buyer_deal_milestones_recycler_view_setup_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="18dp"
android:layout_marginTop="31dp"
android:layout_marginEnd="18dp"/>
</LinearLayout>
</RelativeLayout>```