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的第一個參數一樣.