2012-08-03 4 views
1

NumberPicker를 만들었지 만 비어 있습니다. 텍스트 필드 이외의 다른 부분은 클릭 할 수 없습니다.이 "0"은 내가 키패드를 팝업 할 때 나타납니다. 내가 의미하는 바를 분명히하기위한 그림이있다.안드로이드 API의 빈 NumberPicker

는 사진 :

Dialog dialog = new Dialog(SettingsActivity.this); 
dialog.setContentView(R.layout.draws_dialog); 
dialog.show(); 

SettingsActivity 내가 만들고이 대화 상자를 보여 활동 : 여기 enter image description here

내가 대화 상자를 만드는 데 사용하는 코드입니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"> 

    <NumberPicker 
     android:id="@+id/numberPicker1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" /> 

</RelativeLayout> 

그래서 어떤 아이디어는 내가 잘못 여기서 뭐하는 오전 :

여기 내 대화의 XML인가?

+0

당신은에서 onCreate 안에 당신의 대화 상자를 표시하고 있습니까? – Erol

+0

내 내장 대화 상자에 내 대화 상자가 표시됩니다. 안에있는 것은 클릭하십시오 onCreate –

답변

2

이 같은 예를 들어, NumberPicker에 대한 최소 및 최대 값을 설정해야합니다

int minValue = 5; 
int maxValue = 20; 
int currentValue = 10; 

final NumberPicker uiCapacity = findViewById(R.id.capacity); 
uiCapacity.setMinValue(minValue); 
uiCapacity.setMaxValue(maxValue); 
uiCapacity.setValue(currentValue); 
0

귀하의 NumberPicker이 스타일 Holo.Light가 없습니다. this 질문을 참조하십시오.

이 같은 AlertDialog 만들기 :

 View npView = getLayoutInflater().inflate(R.layout.number_picker_dialog, null); 

    NumberPicker mPicker = (NumberPicker)npView.findViewById(R.id.npQuantity); 
     mPicker.setMaxValue(100); 
     mPicker.setMinValue(0); 

    new AlertDialog.Builder(this) 
     .setTitle("Quantity:") 
     .setView(npView) 
     .setPositiveButton("OK", 
      new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int whichButton) { 
        //"OK" clicked 
       } 
      }) 
     .setNegativeButton("Cancel", null) 
     .show(); 
관련 문제