HuanHaiLiuXin/CoolViewPager

There is no children in ViewPager

Closed this issue · 2 comments

I've added CoolViewPager in my xml like this:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" >
    <com.huanhailiuxin.coolviewpager.CoolViewPager
        android:id="@+id/vp"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</layout>

and set ip up in code like this:

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

            binding = DataBindingUtil.inflate(inflater, R.layout.fragment_assort, container, false)

            binding.vp.adapter = object: FragmentPagerAdapter(fragmentManager) {
                override fun getItem(position: Int): Fragment {
                    return when (position) {
                        0 -> MeterdAssormentFragment()
                        1 -> ContinuousAssortmentFragment()
                        else -> throw IllegalArgumentException("Not supported")
                    }
                }

                override fun getCount(): Int = 2
            }
    }

I can scroll, overscroll indicators appear, but there is nothing on screen. I checked layout inspector and it shows that vp element does not have any child elements...

Fragment is not yet supported for coolViewPager,i may add this feature in the future.
Thanks for you issue!

I've added CoolViewPager in my xml like this:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" >
    <com.huanhailiuxin.coolviewpager.CoolViewPager
        android:id="@+id/vp"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</layout>

and set ip up in code like this:

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

            binding = DataBindingUtil.inflate(inflater, R.layout.fragment_assort, container, false)

            binding.vp.adapter = object: FragmentPagerAdapter(fragmentManager) {
                override fun getItem(position: Int): Fragment {
                    return when (position) {
                        0 -> MeterdAssormentFragment()
                        1 -> ContinuousAssortmentFragment()
                        else -> throw IllegalArgumentException("Not supported")
                    }
                }

                override fun getCount(): Int = 2
            }
    }

I can scroll, overscroll indicators appear, but there is nothing on screen. I checked layout inspector and it shows that vp element does not have any child elements...

Had the same issue, so when is support for Fragments gonna be available