Pregunta

I am new to Android development, and have tried researching my question but can not find a suitable answer.

What I am trying to do is create a list of items, like the numbers 0-9 for example, and display that as a list that the user can scroll up or down to select the desired number, starting at 0.

The best example that I can think of is the HTC Sense timer, linked below (can not post pictures as a new user):

Sense Timer:

enter image description here

What I currently have is a Spinner, but that's not exactly what I want. I want the user to simply swipe up/down to make their selection, not press a button to bring up a drop-down list to make their selection.

Is there a simple way to do this that I am missing, or is it a fairly complicated thing to do? I have not been able to find an example on my own.

Thanks

¿Fue útil?

Solución

This is simply known as Wheel View in android. I am not much aware of its implementation, but here is a very good demo. Take a look at it.

http://android-devblog.blogspot.in/2010/05/wheel-ui-contol.html

This will get you started with it.

Here is another one,

http://android-devblog.blogspot.in/2011/01/android-wheel-update-custom-views-for.html

Otros consejos

Try ScrollView, may this will work:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

 <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

//Your Components

    </RelativeLayout>

</ScrollView>

You need to use a listview and an adapter for this. Its a very simple way to implement the vertical scrolling list of items. Please refer the code from the following link: http://developer.android.com/resources/tutorials/views/hello-listview.html

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top