2012-12-01 23 views
3

我正在嘗試使用simonvt數字選取器。我已經成功地將庫添加到了我的項目中,並且已成功地運行了包含庫的示例項目。 但在我的項目,我得到這個異常:使用simonvt數字選取器時的ClassCastException

12-01 21:39:48.543:E/AndroidRuntime(987):了java.lang.RuntimeException:無法啓動>活動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> 

和我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); 
    } 
+0

發佈您的相關代碼並指明發生此錯誤的位置。 – Sam

+0

編輯並添加我的代碼 – kaplanfat

回答

3

看來你輸入:

import android.widget.NumberPicker; 

但是你要打算使用:

import net.simonvt.widget.NumberPicker; 
+0

多麼愚蠢我非常感謝你花花公子:) – kaplanfat

相關問題