1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| class BlankFragment : Fragment() { var ctx:Context? = null var mPosition:Int = 0 var mInageId:Int = 0 var mDesc:String = "" var title:String = ""
val colorNames = listOf<String>("红色","黄色","绿色","青色","蓝色") val colors = intArrayOf(Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE) var mSeq:Int = 0 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { ctx = activity if (arguments != null) { mPosition = arguments!!.getInt("position", 0) mInageId = arguments!!.getInt("image_id", 0) mDesc = arguments!!.getString("desc") title = arguments!!.getString("title") } val view = inflater.inflate(R.layout.show_info, container, false)
view.findViewById<ImageView>(R.id.imageView).setImageResource(mInageId) view.findViewById<TextView>(R.id.textView).text = mDesc return view }
companion object { fun newInstance(position:Int, image_id:Int, desc:String, title:String) : BlankFragment {
val fragment = BlankFragment() val bundle = Bundle() bundle.putInt("position", position) bundle.putInt("image_id", image_id) bundle.putString("desc", desc) bundle.putString("title", title) fragment.arguments = bundle return fragment } } }
|