2013-06-06 2 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); 

을 보여주기 위해 당신이이 감소 피커의 바닥 부분을 클릭하면, 최소 및 최대 값을 설정해야 전화 번호