在Parse.com应用程序中向Post添加新字段

时间:2014-09-23 22:24:30

标签: java android eclipse parse-platform

//这是我今天早些时候发布的帖子的更新。

我想在Parse.com的Anywall应用程序的Post对话框中填充一些字段。使用下面的代码,我只能填充一个字段。有谁看到我做错了什么?我认为问题可能与alert.setView

有关
     // Create the builder where the new post is entered
    AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
    alert.setTitle("Create a Bicyclist Count Post");
    final EditText input = new EditText(MainActivity.this);
    final EditText inputNotes = new EditText(MainActivity.this);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    inputNotes.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    alert.setView(input);
    alert.setView(inputNotes);
    // Handle the dialog input
    alert.setPositiveButton("Post", new DialogInterface.OnClickListener() {
      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());

//结束更新

我想允许用户在Parse.com的示例Anywall应用程序的Post屏幕中填充其他字段。我通过我的Parse.com帐户在表格中添加了新列bicyclistCount: enter image description here

我无法在Post屏幕中显示它。用户在下图中输入文本的区域将填充文本列。有人能够在Anywall应用程序中为其帖子添加其他字段吗?谢谢

enter image description here

1 个答案:

答案 0 :(得分:1)

这是一种简单的技术。尝试使用edittext方向添加linearlayout中的所有vertical,然后将此布局(视图)设置为alert dialog,例如:

AlertDialog.Builder alert = new AlertDialog.Builder(context);
        alert.setTitle("Create a Bicyclist Count Post");

        LinearLayout layout = new LinearLayout(context);

        LinearLayout.LayoutParams params = 
                new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

        layout.setOrientation(LinearLayout.VERTICAL);

        layout.setLayoutParams(params);

        final EditText input = new EditText(context);

        final EditText inputNotes = new EditText(context);

        //do your remaining stuff with input and inputNotes

        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
        inputNotes.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

        layout.addView(input);
        layout.addView(inputNotes);


        alert.setView(layout);

        alert.show();