2013-06-06 13 views
9

私のレイアウトにNumberPickerを追加し、私のアプリケーションをデバッグしました。今ではNumberPickerが機能していないことがわかります。 "+"または " - "ボタンが表示されず、キーボードの数字をクリックしても何も起こりません。Android:NumberPickerは動作しません

Here's私のレイアウトファイル:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:background="#99cc00" 
tools:context=".Gewichtsentwicklung" > 

<NumberPicker 
    android:id="@+id/numberPicker1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="80dp" /> 

<TextView 
    android:id="@+id/tvGewichtUeberschrift" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_centerHorizontal="true" 
    android:textColor="@color/white" 
    android:textSize="13pt" 
    android:layout_alignParentTop="true" 
    android:text="Aktuelles Gewicht eingeben" /> 

<Button 
    android:id="@+id/btGewicht" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_below="@+id/numberPicker1" 
    android:layout_marginTop="79dp" 
    android:text="Gewicht speichern" /> 

Where's問題?

答えて

27

実際に数値ピッカーに値を入力していますか?以下に示すように?

NumberPicker np = (NumberPicker) findViewById(R.id.numberPicker1); 
String[] nums = new String[20]; 
for(int i=0; i<nums.length; i++) 
     nums[i] = Integer.toString(i); 

np.setMinValue(1); 
np.setMaxValue(20); 
np.setWrapSelectorWheel(false); 
np.setDisplayedValues(nums); 
np.setValue(1); 
3

番号ピッカーは、スクロールホイールのよりとしての+または-シンクタンクを持っていません。あなたはピッカーの底部分をクリックすると、あなたは、それが数を増加させ、ピッカーの上部をクリックした場合、それは減少し、それが何かを表示するための最小数と最大数を設定する必要が本当に

setMinValue(5); 
setMaxValue(120); 

番号

関連する問題