很简单,我有一个'localNotification' was deprecated in iOS 10.0: Use UserNotifications Framework's -[UNUserNotificationCenterDelegate didReceiveNotificationResponse:withCompletionHandler:]
,其中的某些图像包含在viewpager
布局中。当我运行项目时,所有的布局都会显示出来,但是fragment
却不会……就像这样:
因此,我将重要的代码放在这里。首先,viewpager
:
Viewpager
各自的片段:
class ViewPageAdapter(private val context: Context) : PagerAdapter(){
private var layoutInflater:LayoutInflater?= null
override fun isViewFromObject(view: View, `object`: Any): Boolean {
return view === `object`
}
override fun getCount(): Int {
return images.size
}
override fun instantiateItem(container: ViewGroup, position: Int): Any {
/**Set our vals to "inflate"**/
layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val v = layoutInflater!!.inflate(R.layout.custom_layout, null)
val image = v.findViewById<View>(R.id.image_view) as ImageView
/**Positions of images**/
auxPosition = images[position]
val vp = container as ViewPager
/** Add custom_layout.xml to our viewpager**/
vp.addView(v, 0)
return v
}
}
viewpager的布局:
class FeridasFragment : Fragment() {
internal lateinit var viewPager: ViewPager
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val conteudo_feridas=inflater!!.inflate(R.layout.fragment_feridas, container, false)
//the viewpager
viewPager = conteudo_feridas.findViewById<View>(R.id.viewPagerGaleria) as ViewPager
val adapter = ViewPageAdapter(activity!!.application)
viewPager.adapter = adapter
viewPager.currentItem = images.size
//nav dots of viewpager
val pageIndicatorView = conteudo_feridas.findViewById<View>(R.id.pageIndicatorView) as PageIndicatorView
pageIndicatorView.setViewPager(viewPagerGaleria)
pageIndicatorView.count = images.size
pageIndicatorView.selection = images.size
return conteudo_feridas
}