Skip to content

Instantly share code, notes, and snippets.

@muzafakar
Created September 17, 2019 13:39
Show Gist options
  • Save muzafakar/45bbb84780f3ba988300d143abb18709 to your computer and use it in GitHub Desktop.
Save muzafakar/45bbb84780f3ba988300d143abb18709 to your computer and use it in GitHub Desktop.
class RegisterAddressFragment : FragmentViewModel() {
private val provinceList = mutableListOf<String>()
private lateinit var adpProvince: ArrayAdapter<String>
override fun onCreate(savedInstanceState: Bundle?) {
/*
provinceList sudah terisi dari LiveData
*/
adpProvince = ArrayAdapter(context!!, android.R.layout.simple_spinner_item, provinceList)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.fragment_register_address, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// set adapter to spinner
spProvince.adapter = adpProvince
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment