Question

I'm trying to use simonvt number picker. I have added the library succesfully to my project and I have run sample project with library successfully. But in my project I get this exception :

12-01 21:39:48.543: E/AndroidRuntime(987): java.lang.RuntimeException: Unable to start >activity ComponentInfo{com.tekna.digiguide/com.tekna.digiguide.KayitHourPickerActivity}: >java.lang.ClassCastException: net.simonvt.widget.NumberPicker

Can anyone help?

my xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <net.simonvt.widget.NumberPicker
        android:id="@+id/numberPicker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <Button
        android:id="@+id/buttonPickerEkle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

and my actvity

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.pickerlayout);

        final NumberPicker np = (NumberPicker) findViewById(R.id.numberPicker);
        np.setMaxValue(24);
        np.setMinValue(1);
        np.setFocusable(true);

        np.setFocusableInTouchMode(true);
    }
Was it helpful?

Solution

It appears you imported:

import android.widget.NumberPicker;

But you want meant to use:

import net.simonvt.widget.NumberPicker;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top