繁体   English   中英

使用 simonvt 数字选择器时出现 ClassCastException

[英]ClassCastException when using simonvt number picker

我正在尝试使用 simonvt 号码选择器。 我已成功将库添加到我的项目中,并且已成功运行带有库的示例项目。 但在我的项目中,我得到了这个例外:

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

任何人都可以帮忙吗?

我的 xml 文件

<?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>

和我的活动

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);
    }

看来您导入了:

import android.widget.NumberPicker;

但你想要使用:

import net.simonvt.widget.NumberPicker;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM