当我向 Parse 提交新帖子时应用程序崩溃 [英] App crash when I submit a new post to Parse

查看:12
本文介绍了当我向 Parse 提交新帖子时应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的应用程序崩溃的唯一地方,也是更重要的功能之一

This is the only Place my app crashes and one of the more important features

LogCat 告诉我:

The LogCat tells me:

java.lang.IllegalArgumentException:您必须使用 ParseObject.create() 或适当的子类创建这种类型的 ParseObject.在第 37 行.

java.lang.IllegalArgumentException: You must create this type of ParseObject using ParseObject.create() or the proper subclass. at line 37.

我尝试了 ParseObject.create() 但这只会引起更多问题(我可能做错了).我应该如何编码?

I tried the ParseObject.create() however that just caused more problems (I may have done it incorrectly). How Should I code this?

这是我的 newPost 类:

Here is my newPost class:

public class newPost extends Activity {

private Button addButton;

private TextView postView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.newpost);

    postView = ((EditText) findViewById(R.id.postView));

    addButton = ((Button) findViewById(R.id.addButton));
    addButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //line 37 Below
            ParseObject post = new ParseObject("Posts");
            post.put("content", postView);
            post.saveInBackground(new SaveCallback () {

                @Override
                public void done(ParseException e) {
                    if (e == null) {
                        setResult(RESULT_OK);
                        finish();
                    } else {
                        Toast.makeText(getApplicationContext(),
                                "Error saving: " + e.getMessage(),
                                Toast.LENGTH_SHORT)
                                .show();
                    }
                }

            });

        }
    });



}

推荐答案

替换此行

ParseObject post = new ParseObject("Posts");

有了这个

ParseObject post = ParseObject.create("Posts");

这篇关于当我向 Parse 提交新帖子时应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆