美文网首页Android学习
Kotlin如何在Fragment中直接使用控件ID号

Kotlin如何在Fragment中直接使用控件ID号

作者: 爱在记忆消失前 | 来源:发表于2018-05-08 09:37 被阅读97次

    package com.njsoft.jcyy.good.goodfragment

    import android.os.Bundle

    import android.support.v4.app.Fragment

    import android.view.LayoutInflater

    import android.view.View

    import android.view.ViewGroup

    import com.njsoft.jcyy.R

    import com.njsoft.jcyy.shop.shopadapter.CommonTabPagerAdapter

    import kotlinx.android.synthetic.main.fragment_blank.*

    import java.util.*

    /**

    * A simple [Fragment]subclass.

    *

    */

    class GoodDetailFragment : Fragment(), CommonTabPagerAdapter.TabPagerListener {

    override fun getFragment(position: Int): Fragment {

    return GoodFragment()

    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,

    savedInstanceState: Bundle?): View? {

    // Inflate the layout for this fragment

            return inflater.inflate(R.layout.fragment_blank, container,false)

    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

    super.onViewCreated(view, savedInstanceState)

    //此处可以直接用ID

    initViewPager()

    }

    private fun initViewPager() {

    val adapter = CommonTabPagerAdapter(activity!!.getSupportFragmentManager(), Arrays.asList("商品介绍","规格参数","资质证明","包装售后"),activity)

    adapter.setListener(this)

    GoodViewPager.setAdapter(adapter)

    GoodViewPager.setScroll(false)

    GoodDetailTablayout.setupWithViewPager(GoodViewPager)

    }

    }

    相关文章

      网友评论

        本文标题:Kotlin如何在Fragment中直接使用控件ID号

        本文链接:https://www.haomeiwen.com/subject/gslirftx.html