-1

I'm trying to get the value from Android SpinnerWheel. There are very few post in SO giving answer for this and not one post shows any true information. I found only one link which was a bit descriptive but still didn't have the result I wanted. So if anyone can show me how exactly we can get the value and set it in a TextView, it will be really great

My Code

public class MainActivity extends Activity {
 TextView textvalue;
 String value;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  
  textvalue = (TextView)findViewById(R.id.textvalue);
  
   final AbstractWheel mins = (AbstractWheel) findViewById(R.id.mins);
         NumericWheelAdapter minAdapter = new NumericWheelAdapter(this, 0, 59, "%02d");
         minAdapter.setItemResource(R.layout.wheel_text_centered_dark_back);
         minAdapter.setItemTextResource(R.id.text);
         mins.setViewAdapter(minAdapter);
         
         
         
         //OnWheelChangedListener listener = null;
   //mins.addChangingListener(listener);
         
   
 }
 
  private OnWheelChangedListener changedListener = new OnWheelChangedListener() {
         public void onChanged(AbstractWheel wheel, int oldValue, int newValue) {
          String value = String.valueOf(newValue);
          textvalue.setText(value);
         }
     };
 
 
 
 
 

 
}

.

Community
  • 1
  • 1
Somnath Pal
  • 1,570
  • 4
  • 23
  • 42
  • Please be more clear..which result You want to have and which one is the result you get..... – Opiatefuchs Jan 27 '16 at 14:07
  • My question is really very simple. I want the value which is the focus of the spinner wheel. When you scroll the wheel, the focus changes from number to number. I too want my TextView value to change when the focus changes. – Somnath Pal Jan 27 '16 at 14:15
  • but You had not described what the result ist. Please giva an example, like: You want to get a number (e.g. 1) but You get the wrong number...something like this.....or is Your textView just empty? – Opiatefuchs Jan 27 '16 at 14:17
  • I'm not getting any value using my code. TextView value remains blank. – Somnath Pal Jan 27 '16 at 14:26
  • And why You have commented out "mins.setChangingListener()" ? You had not added the listener to Your wheel... – Opiatefuchs Jan 28 '16 at 07:04

1 Answers1

0

The only thing I see is, that You haven´t added the listener to Your wheel, because You had commented it out:

     //mins.addChangingListener(listener);

It must be:

     mins.addChangingListener(changedListener);
Opiatefuchs
  • 9,800
  • 2
  • 36
  • 49