更新,我通過調用onValueChangedListener最終得到了這個工作。將NumberPicker值添加到數據庫中
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) {
}
});
並且當我發佈到Parse.com數據庫時調用該值。謝謝。
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);
結束更新。
我想將我的NumberPicker中的值添加到我爲我的應用程序設置的後端Parse.com數據庫中。我已將NumberPicker添加到Post表單。當我在保存帖子後查看錶格時,我沒有看到數字,而是一個無意義的文字條目。有沒有人有什麼需要添加到我的代碼的建議?謝謝。
的NumberPicker代碼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);
我節省了輸入的代碼在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.
郵政形式與NumberPicker:
我還沒有得到的Parse.com表與NumberPicker值來填充。它寫了類似com.parse.anywall.MainActivity ...到該字段。
你是如何得到Picker的價值的?它似乎並不像你在讀它。 – 2014-10-03 20:35:04
謝謝@CarlosJ。我現在已經獲得了價值,就像我在下面提到的那樣。在我的表中結果是一樣的。 – 2014-10-04 01:24:06