kotlin android pickerView

864 Views Asked by At

I am a beginner of Kotlin in Android and would like to create an pickerViewer (as below image) in Android Kotlin. enter image description here

I found https://github.com/Bigkoo/Android-PickerView on the web, but I don't know how to use it because the code is Java. I am asking for the solution with source code. Please kindly help.

1

There are 1 best solutions below

1
On

java

TimePickerView pvTime = new TimePickerBuilder( this, new OnTimeSelectListener() {
    @Override
   public void onTimeSelect(Date date, View v) {
       Toast.makeText(MainActivity.this, getTime(date), Toast.LENGTH_SHORT).show();
   } }).build();

kotlin

 val pvTime = TimePickerBuilder( this, {  date, v  ->
       Toast.makeText(MainActivity.this, getTime(date), Toast.LENGTH_SHORT).show() 
   }  ).build() 

you can first code in java, then use "Code> convert to Kotlin" in the android studio, so that you can compare between the two.