键盘打开时调用Viewpager2 onPageSelected

时间:2019-09-16 12:41:01

标签: android kotlin android-viewpager2

我已经实现了Viewpager2并有2个片段,每当我打开键盘时,就会调用onPageSelected的{​​{1}},并且所选页面首先显示在第一个页面上,然后转到第二个

ViewPager2.OnPageChangeCallback()

我尝试设置viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { override fun onPageSelected(position: Int) { super.onPageSelected(position) selectedPos = position if (position == 1) { ivBackVp.visibility = View.VISIBLE progress.progress = 100 if (userType == Const.TYPE_PARENT) { tvStepDescription.text = getString(R.string.create_profile_step_two) } else { tvStepDescription.text = getString(R.string.create_profile_step_two_child) } tvNext.text = getString(R.string.done) } else { ivBackVp.visibility = View.GONE progress.progress = 50 if (userType == Const.TYPE_PARENT) { tvStepDescription.text = getString(R.string.create_profile_step_one) } else { tvStepDescription.text = getString(R.string.create_profile_step_one_child) } tvNext.text = getString(R.string.next) } } }) ,但也失败了。请以合理的理由帮助我,说明为什么它必须被调用以及我应该怎么做才能解决这个问题。

0 个答案:

没有答案