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

标签 java android eclipse parse-platform

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

我想在 Parse.com 的 Anywall 应用程序的“发布”对话框中填充一些字段。使用下面的代码我只能填充一个字段。有人看到我做错了什么吗?我认为问题可能与 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应用。我通过我的 Parse.com 帐户在表中添加了新列 bicyclistCount: enter image description here

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

enter image description here

最佳答案

这是一个简单的技术。尝试将所有edittext添加到垂直方向的线性布局中,然后将此布局( View )设置为警报对话框例如:

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();

关于java - 在 Parse.com 应用程序中向 Post 添加新字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26005657/

相关文章:

java - 在编写重写方法时,为什么Java中允许调用另一个父类(super class)方法?

java - 重新审视 Jon Skeet 在他的文章中发布的 Java 中的按值传递语义

android - 有效数组适配器

java - 更新的 Android SDK 向我的应用程序添加了错误

Java与Jython,解决路径问题的优雅方式?

java - 如何通过关闭一个阶段并返回到上一个阶段的值而不打开一个新阶段?

java - 使用 Timer 和 ArrayList 更新 TextView

c# - Xamarin:按下后退按钮时关闭警报对话框

c++ - 生成自动变灰的makefile - eclipse

java - 我需要在 Eclipse(对于 Selenium WebDriver)中设置/配置哪些环境变量?如果我不设置/配置它们怎么办?