Bmob.initialize(this, "2ee0487ab1f9e7e28e8cc8a43c5d72df");
Button button1=(Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
final Person p2 = new Person();
p2.setName("lucky");
p2.setAddress("北京海淀");
p2.save(this, new SaveListener() {
@Override
public void onSuccess() {
// TODO Auto-generated method stub
Toast.makeText(HelloWorldActivity.this, "添加数据成功,返回objectId为:"+p2.getObjectId(),Toast.LENGTH_LONG).show();
// toast("添加数据成功,返回objectId为:"+p2.getObjectId());
}
@Override
public void onFailure(int code, String msg) {
// TODO Auto-generated method stub
Toast.makeText(HelloWorldActivity.this,"创建数据失败:" + msg,Toast.LENGTH_LONG).show();
}
});
}
});
报这个错
The method save(Context, SaveListener) in the type BmobObject is not applicable for the arguments (new View.OnClickListener(){}, new SaveListener(){})
具体见http://zhidao.baidu.com/question/2054271950012387947.html
你的参数有问题,把
p2.save(HelloWorldActivity.this, new SaveListener() {
@Override
public void onSuccess() {
// TODO Auto-generated method stub
Toast.makeText(HelloWorldActivity.this, "添加数据成功,返回objectId为:"+p2.getObjectId(),Toast.LENGTH_LONG).show();
// toast("添加数据成功,返回objectId为:"+p2.getObjectId());
}
@Override
public void onFailure(int code, String msg) {
// TODO Auto-generated method stub
Toast.makeText(HelloWorldActivity.this,"创建数据失败:" + msg,Toast.LENGTH_LONG).show();
}
});
这样在试试,save(Context, SaveListener)第一个要传递Context类型的,跟Toast的第一个参数一样.