Hello guys! I am new to Kotlin and I cannot figure out to display more then 3 elements in a wheel. For example if the array is 1 to 10 the wheel will display (wheel is wraped)
10
1
2
I am trying to have the wheel to display 5 elements (should look something like this)
9
10
1
2
3
I look through stackoverflow and find out there is this code that is set to 3
SELECTOR_WHEEL_ITEM_COUNT = 3
This code is not in Kotlin and thus does not work
This has been very difficult and not sure if I am missing something.
What platform are you developing for? I guess it is android, but it would be good to know.
Also can you show some code snipet? How do you create the wheel? Where do you set the data? Also please only post parts of your code and not everything.
As for the SO answer. I don’t know what you found exactly, but it looks like they are defining a constant for the number of items to display. If you go back to the SO post, try to look at where else they use that constant. That should tell you how to set the number of items displayed.
Sorry, its in android studio. The post I was talking about was this one but it’s for Java (I could not find much info on number picker for Koltin)
I assume the code SELECTOR_WHEEL_ITEM_COUNT does not work in Kotlin and could not find similar code
I am creating a memorization app and using the wheel to select the chapter and verses. There is a total of 3 wheels. Here are the arrays, The arrays are in values > array_lists.xml
I’m guessing you are using a NumberPicker(NumberPicker | Android Developers).
Based on the documentation I don’t think it is possible to change the number of elements displayed, at least not with this widget.
Also while looking for the number picker I found this which might help you.
Thank you! and sorry but I need a little bit of help! This is the first time I import anything to my build. I have done what the package tab said and sync’d android studio but it still does not recognize the chapterWheel.setWheelItemCount(5)
This is my build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.70'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
task clean(type: Delete) {
delete rootProject.buildDir
}