Reputation: 235
Update, I got this working finally by calling an onValueChangedListener.
layout.setLayoutParams(params);
final EditText input = new EditText(MainActivity.this);
final EditText inputNotes = new EditText(MainActivity.this);
final NumberPicker inputCount = new NumberPicker(MainActivity.this);
inputCount.setMaxValue(50);
inputCount.setMinValue(0);
inputCount.clearFocus();
inputCount.setOnValueChangedListener( new NumberPicker.
OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int
oldVal, int newVal) {
}
});
And calling that value when I post to the Parse.com database. Thank you.
public void onClick(DialogInterface dialog, int which) {
// Create a post.
AnywallPost post = new AnywallPost();
// Set the location to the current user's location
post.setLocation(myPoint);
post.setText(input.getText().toString());
post.setNotes(inputNotes.getText().toString());
final int valueCount = inputCount.getValue(); //getting valueCount from above
post.setNumber(valueCount);
End update.
I want to add the value from my NumberPicker to the backend Parse.com database I have set up for my app. I've added the NumberPicker to the Post form. When I look at the table after saving a Post, I don't see a number but a nonsense text entry. Does anyone have suggestions on what I need to add to my code? Thanks.
The NumberPicker code in MainActivity:
layout.setLayoutParams(params);
final EditText input = new EditText(MainActivity.this);
final EditText inputNotes = new EditText(MainActivity.this);
final NumberPicker inputCount = new NumberPicker(MainActivity.this);
inputCount.setMinValue(0);
inputCount.setMaxValue(50);
I'm saving the input with code further down in MainActivity.
public void onClick(DialogInterface dialog, int which) {
// Create a post.
AnywallPost post = new AnywallPost();
// Set the location to the current user's location
post.setLocation(myPoint);
post.setText(input.getText().toString());
post.setNotes(inputNotes.getText().toString());
post.setNumber(inputCount.getContext().toString()); //This is where value for NumberPicker is saved. I need to change this line, I think.
The Post form with the NumberPicker:
I haven't gotten the Parse.com table to populate with the NumberPicker value. It writes something like com.parse.anywall.MainActivity... to that field.
Upvotes: 0
Views: 393
Reputation: 235
I called setOnValueChangedListener
for my NumberPicker and used that value to add to my database. I put code in update to the question. Thanks.
Upvotes: 0
Reputation: 126523
Have you tried saving :
Integer.toString(inputTime.getValue());
Upvotes: 1