ipdan4ik

[lb8] LeftFragment.kt

Apr 18th, 2021
559
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.lb8
  2.  
  3. import android.content.Context
  4. import android.os.Bundle
  5. import android.view.LayoutInflater
  6. import android.view.View
  7. import android.view.ViewGroup
  8. import android.widget.ArrayAdapter
  9. import android.widget.ListView
  10. import androidx.fragment.app.Fragment
  11.  
  12. class LeftFragment() : Fragment() {
  13.     override fun onCreateView(
  14.         inflater: LayoutInflater,
  15.         container: ViewGroup?,
  16.         savedInstanceState: Bundle?): View? {
  17.         val view = inflater.inflate(R.layout.fragment_left, container, false)
  18.  
  19.         val listOptions = view.findViewById<ListView>(R.id.list_fruits)
  20.         listOptions.adapter = ArrayAdapter<String>(context!!,
  21.             R.layout.my_list_item,
  22.             arrayOf("+", "-", "*"))
  23.         listOptions.setOnItemClickListener { parent, view, position, id ->
  24.             (mainContext as OnDataListener).onData(position)
  25.         }
  26.  
  27.         return view
  28.     }
  29.  
  30.     override fun onAttach(context: Context) {
  31.         super.onAttach(context)
  32.         mainContext = context
  33.     }
  34.     private lateinit var mainContext: Context
  35.  
  36.  
  37. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×