_Ziens_

Untitled

Sep 18th, 2021 (edited)
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MainActivity : AppCompatActivity() {
  2.  
  3.     override fun onCreate(savedInstanceState: Bundle?) {
  4.         super.onCreate(savedInstanceState)
  5.  
  6.         ActivityMainBinding.inflate(layoutInflater).apply {
  7.             with(sCountry) {
  8.                 adapter =
  9.                     ArrayAdapter(
  10.                         this,
  11.                         R.layout.item_country,
  12.                         R.id.tvCountry,
  13.                         OperatedCountry.values()
  14.                     )
  15.                 onItemSelectedListener =
  16.                     object : AdapterView.OnItemSelectedListener {
  17.                         override fun onItemSelected(
  18.                             parent: AdapterView<*>,
  19.                             view: View?,
  20.                             position: Int,
  21.                             id: Long
  22.                         ) {
  23.                             if (view != null) {}
  24.                         }
  25.  
  26.                         override fun onNothingSelected(parent: AdapterView<*>) {}
  27.                     }
  28.             }
  29.  
  30.             setContentView(binds.root)
  31.         }
  32.     }
  33. }
  34.  
  35. enum class OperatedCountry(val countryCode: String, val icon: Int) {
  36.     RUSSIANFEDERATION("RU", R.drawable.flag_400),
  37.     UKRAINE("UK", R.drawable.flag_401),
  38.     TURKEY("TR", R.drawable.flag_402),
  39. }
  40.  
Add Comment
Please, Sign In to add comment