How to delete using long click or using swipe to delete - android

I have a listview that is working fine. Now I have one option to enable and that is deleting the row. I know this is not a problem But Want to take some suggestions. and that is what is a best way of deleting the item(row). Here what I have tries I am sharing with you
Used Context Menu on long click but they do not look cool and quite old.
Used Swipe to Delete but there comes some problems which are not working good, I mean there are some problems in it. here is the reference of my question about that.
Can any one please come up with some suggestion of deleting the row which are new and good ways to do so.
What are prerequisites :
I am using fragments with one single activity and using tool bar so I really can use delete option appearing in toolbar for only one fragment . Actually I do not know how to do it.
So please tell me what are the good and best way which are user friendly , looks good in gui and also a Beginner developer friendly

One solution is,
Add hidden checkbox in each listview row.
Add delete button on the toolbar/actionbar.
OnClicking delete button show checkboxes to select multiple items to
delete.
Again clicking on delete should ask confirmation dialog and delete if user agrees.

You can use Recyclerview instead of ListView. It has default animation while adding/removing items. You can check the code here or you can provide cross icon in the item and delete on click of it.

Related

Android drag & drop

Before that I start explaining the problem I need to say one thing: I'm totally new to android programming, I can use java without problem, but i still don't know the android packages and classes.
I have a LinearLayout with 2 columns, inside the first column there are some buttons, the second contains a scrollView, in this scrollViewthere should be some... items that the user can add, those items have a title and a text, i already defined thoose objects in another class, and i add them to the scrollViewfrom a button.
From now i put in that object a button that is used to delete the item, but now i realized that it's really ugly, so i was thinking: is it possible to allow the user to drag and drop the item out of the screen to delete it?
I could surely do it by managing the event of pression and release on the item with some listener, but i'm almost sure that there's some android class created for sliding UI components.
Something like what you do with android notification.
I post an image of how the current app is so you can understand better what i said: http://i.stack.imgur.com/fHWK3.jpg (I don't have enough reputation to post images)
If i wasn't clear just say and i will edit with the requested information.
UPDATE: After reading the resource that Bonatti posted in his answer i added a OnLongClickListener for starting the drop, and a OnDragListener to look the cordinates during the drag, now i have a problem... I need my component to be dragged only horizzontally like how you usually remove notification from the notification bar, i thought about the fact that i could save the Y-location of the shadow created by the DragShadownBuilder when i create it, and then i could check in the OnDrag event if the Y-location now is different from the beginning i correct it, but the problem is... how can i access the shadow's location?
The basics of what you are asking for can be found here:
I cant post more than 2 links, so redo these:
http:// developer.android.com/guide/topics/ui/ drag-drop.html
These other might help with what you need in details:
Link 1: code.tutplus Or Link 2: vogella
They both answer what you need.
To put it simple:
You need an "action" to receive that a button/something was pressed (and that is still being pressed), and then update the screen to match the item position

Delete list item - Android concept

What is Android's concept of deleting a list item? I thought of something like long-pressing it which will pop-up a dialog box to confirm / reject...
But would like to know what is the most popular way of doing it in Android.
Thanks!
This question is regarding to UX design. Generally speaking, the most popular approach of deleting items are:
Long press and pop up context menu
On action bar, entering selection mode and then choose the action
Slide to right/left and display a delete indicator on the item
You might choose/combine appropriate methods.
I have found this link may explain everything you need for the deletion in list view.
https://ux.stackexchange.com/questions/48112/typical-android-app-behavior-for-deleting-data-from-a-list

Android: ListView filtering from a dropdown menu OR checkboxes

I've been browsing these and other "forums" for quite a bit and I've not been able to find a "guide" to this issue I'm facing.
I've had an Android course and I decided to start working on my own app, everything was going smooth until I got to this point: I got a custom listview with several items. Now I want to have either a dropdown menu just above the listview or a few checkboxes so that the user can filter said items according to his selection.
Every tutorial I've read talks about filtering the listview thru an edittext field and the user input, but I want the user to click a button and the filter run.
Has anyone out here got a tutorial/guideline on how can I do this?
Thanks and cheers for your time!
Yours,
/D~
Answering myself as I've managed to do this:
As many internet tutorials show, just make your custom adapter implement Filterable and then create a custom Filter that satisfies your criteria - there's plenty of internet tutorials for this, but I could prolly attach the code if someone needs it.
After that's done, all you need to do is call: adapter.getFilter().filter(yourControlString) from the button/spinner item.
yourControlString will basically tell your custom Filter what do you want to display and what you don't want to - you've to customize that on your CustomFilter. Again, this sounds harder than what it really is.

Expandable Animation menu

I want to build an application and I like very much the H&M menu. Anyone can help me with some ideas how to build this kind of menu on android?
It’s an expandable menu which appear when you click on the H&M Logo.
http://img822.imageshack.us/img822/7509/hmmenu.png
The best way to go about this is implementing a Custom View in your application.
What I would recommend is to develop a ViewStub that you can drop-in and populate whenever the user presses the button. This way, you can reuse it across screens, and there is only one thing to change if you need to add/remove an item.
Hope this helps!

ANDROID: I need to create a static menu at the top of the view (like Create, Edit)

I have a menu for about, exit.
But i need to create another static menu for options.
I will prefer to be at the top of the list that i have.
like:
Create, Edit
List
and when i press the menu button to open the (Exit,About).
If You can help, it will be perfect.
Thank you , have a good day.
Please see this post, and this one. The second post has nothing to do with what you want, it's just a nifty way to spruce up your UI by adding a QuickAction. The first post shows you how to build an "ActionBar" for Android.

Categories

Resources