嘿伙计我在解析中删除对象时遇到了一些麻烦,我的应用程序基本上是允许用户登录然后添加,删除和选择课程。但是我目前的问题是每次点击"删除按钮"它总是提出祝酒词#34;没有发现任何课程"我已设置为在对象不存在时显示。但是我确保它确实存在于我的解析数据库中。
这是我的解析表:http://gyazo.com/028cd4816eea96dd9364fc4fbc9fdf76
当按下OnClick侦听器以执行删除按钮时,这是我的代码:
//set onclick listener for delete button
deleteCourse.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
LayoutInflater li = LayoutInflater.from(context);
View deletePromptsView = li.inflate(R.layout.delete_prompt, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
//set the Alert Dialog builder to the delete prompt layout file
alertDialogBuilder.setView(deletePromptsView);
final EditText deleteUserInput = (EditText) findViewById(R.id.editDeleteTextUserInput);
//set the dialog message
alertDialogBuilder.setCancelable(false).setPositiveButton("Delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
//get the user input and send it to parse to delete the object from the table
ParseQuery<ParseObject> query = ParseQuery.getQuery("Course");
//query.whereEqualTo("name", deleteUserInput.getText().toString());
query.getInBackground("name",new GetCallback<ParseObject>() {
@Override
public void done(ParseObject object, ParseException e) {
if (object == null){
Toast.makeText(getApplicationContext(),"No Course Was Found",Toast.LENGTH_LONG).show();
} else{
object.remove(deleteUserInput.getText().toString());
object.deleteInBackground();
}
}
});
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
//Create the alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
//show the alert dialog
alertDialog.show();
}
});
}
答案 0 :(得分:0)
尝试使用此代码,它可以正常使用
UICollectionViewLayout.CreateForCell<CustomLayoutAttributes>(indexPath);