AdvancedAndroid_Shushme
AdvancedAndroid_Shushme copied to clipboard
Recycler view swipe to delete location
Hello, I wonder if there is a feature in app to swipe to delete place, or I'm missing something? Regards, Miroslav Maksimovic
i am also looking for the same but there is no option to delete the added location.
`` RecycleClick.addTo(mRecyclerView).setOnItemClickListener(new RecycleClick.OnItemClickListener() {
@Override
public void onItemClicked(RecyclerView recyclerView, int position, View v) {
SweetAlertDialog pDialog =new SweetAlertDialog(context, SweetAlertDialog.WARNING_TYPE);
pDialog.setTitleText("Delete Location");
pDialog.setContentText("Phone Will No Longer Change Profile Mode Automatically\nYes To Confirm No to Dismiss");
pDialog.setConfirmButton("No", new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sDialog) {
sDialog.dismissWithAnimation();
}
});
pDialog.setCancelButton("Yes", new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sDialog) {
sDialog.dismissWithAnimation();
Uri uri = PlaceContract.PlaceEntry.CONTENT_URI;
int data = getContentResolver().delete(uri,null, null);
Toast.makeText(getApplicationContext(), "Successfully Deleted This Location!",Toast.LENGTH_LONG).show();
}
});
pDialog.setCancelable(true);
pDialog.show();
}
});`
``
i added these lines but i am getting an error of invalid uri
Yep, it's strange that they didn't included swipe to delete or something...
i had the same wish and i did use the method in the attached link to enable onClick WRT the recuclerView and i could enable it
https://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/
This works for you @moharidy ? So I can close the issue.
No it did not, yet , only the onclick part is solved but deleting the selected entry still not coded