2016-08-05 5 views
1

数値ピッカーとしてアラートデイログを使用しています。値を選択してテキストビューに設定できますが、数字ピッカーから5を選択すると、 TextViewに設定され、再びのTextViewに私をクリックした場合、その後5は、あなたがこのように行うことができますnumberpicker以前に選択した値の開始番号ピッカー

public void qtyshow() 
    { 

     final AlertDialog.Builder alert = new AlertDialog.Builder(ProductView.this); 

     alert.setTitle("Select the Qty: "); 

     final NumberPicker np = new NumberPicker(ProductView.this); 


     np.setMaxValue(20); // max value 20 
     np.setMinValue(1); // min value 0 
     np.setWrapSelectorWheel(false); 

     alert.setView(np); 


     alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int whichButton) { 

       proqty.setText(String.valueOf(np.getValue())); //set the value to textview 
       // Do something with value! 



       Float mulprice=Float.parseFloat(packlist.get(0).getProductPack_SP()); 
       int mulqty= np.getValue(); 

       Float total=mulprice*mulqty; 
       packsp.setText("$" + String.format("%.2f%n", total)); 
       System.out.println("price test" + packlist.get(0).getProductPack_SP() + "," + mulprice + "," + mulqty + "," + String.format("%.2f%n", total)); 
       Float mulelseprice=Float.parseFloat(packlist.get(0).getProductPack_ElseWhere()); 
       Float totalelse=mulelseprice*mulqty; 

       packelsewhere.setText("$" + String.format("%.2f%n", totalelse)); 
      } 
     }); 

     alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int whichButton) { 
       // Cancel. 

      } 
     }); 

     alert.show(); 


    } 

答えて

1

に焦点を当て、または選択する必要があります:あなたが参照番号ピッカーのオブジェクトを作成する必要があり@rosy

mNumberPicker.setValue(number); 
+0

。 –

+0

ここに番号は何ですか? – rosy

+0

あなたが設定したいあなたの古い番号 –

関連する問題