gpt4 book ai didi

java - 将 NumberPicker 值添加到数据库

转载 作者:行者123 更新时间:2023-12-01 12:27:57 24 4
gpt4 key购买 nike

更新,我终于通过调用 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) {

}
});

当我发布到 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 表单中。当我保存帖子后查看表格时,我没有看到数字,而是看到了无意义的文本条目。有人对我需要添加到代码中的内容有建议吗?谢谢。

MainActivity 中的 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.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 的 Post 表单:

enter image description here

我还没有使用 NumberPicker 值填充 Parse.com 表。它会向该字段写入类似 com.parse.anywall.MainActivity... 的内容。

enter image description here

最佳答案

您是否尝试过保存:

  Integer.toString(inputTime.getValue());

关于java - 将 NumberPicker 值添加到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26185746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com