Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid- NumberPicker Changed Appearance
    text
    copied!<p>In my application, I'm using a <code>NumberPicker</code> to select number and display it in my TextView.</p> <p>I have two questions regarding this <code>NumberPicker</code> thing. First of all, how can I have a NumberPicker that looks like <code>image B</code> rather in <code>image A</code>? In Image B, that is how I imagine my NumberPicker would be. So far, this is what I have done:</p> <p><img src="https://i.stack.imgur.com/SD3II.png" alt="enter image description here"></p> <p>My NumberPicker Layout:</p> <pre><code> &lt;NumberPicker android:id="@+id/numberPicker" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="64dp" /&gt; &lt;LinearLayout ...&gt; &lt;Button android:id="@+id/btn_set" android:text="Set" /&gt; &lt;Button android:id="@+id/btn_cancel" android:text="Cancel" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Then this is my Activity:</p> <pre><code> public void onSomethingButtonClickedToShowDiaolg(View view){ final Dialog dialog = new Dialog(MyActivity.this); dialog.setContentView(R.layout.number_selector); Button btnSet = (Button) dialog.findViewById(R.id.btn_price_set); Button btnCancel = (Button) dialog.findViewById(R.id.btn_price_cancel); final NumberPicker numberPicker = (NumberPicker) dialog.findViewById(R.id.numberPicker); String[] values = {"5000", "10000", "15000", "20000"}; numberPicker.setDisplayedValues(values); numberPicker.setWrapSelectorWheel(false); numberPicker.setOnValueChangedListener(new OnValueChangeListener() { @Override public void onValueChange(NumberPicker picker, int oldVal, int newVal) { // TODO Auto-generated method stub System.out.println("set number: : " + newVal); } }); btnSet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); btnCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } </code></pre> <p>Then, my other question is this: how can I set in my NumberPicker certain values like... 1000, 3000, 5000, 9000? Because if I use the <code>setMinValue</code> and <code>setMaxValue</code>.. I can have numbers like 1000, 1001, 1002... And so on.</p> <p>Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload