In the Android Mail application, when you click the checkbox next to an inbox message, a little bar with buttons (mark unread, delete, star) appears at the bottom of the screen. I'd like to do something similar, but I don't think I'm going about it the right way.
What I've done is add a LinearLayout below my ListView and marked the visibility GONE. When a user clicks a checkbox next to a list item, the LinearLayout's visibility is marked VISIBLE. Unfortunately, checkboxes stop working. By this I mean the skin on the checkbox does not change from unchecked to checked; and I can't figure out why.
(...or rather, this is the way I HAD it. I removed it once I couldn't fix it and, since trying to add it again, it just crashes, but I digress)
What is the best way to architect what I'm trying to do?
Check out the source of the AndroidMail app that you're referring to. I was able to re-use the CursorAdapter included in MessageList.java with very little modification for one of my apps.
Related
How do I make an Android activity like the one shown in this image.
I am asking specifically about how to make a component such as the repeat and reminder components. And also, the two tabs showing Add Event and Add Task.
I'd also like to know the name by which they are referred.
Touching Repeat, a list dialog box appears. Touching Reminder, different times can be set which can be removed by a minus sign (-) which appears beside them. The tabs cannot be slid, but they need to be clicked to go to a particular tab.
It looks like it's just a listview on top of a tabbed activity.
When you create a new Activity, you can just specify tabbed activity and Android studio takes care of creating the tabs.
Then for the items, you just use listview, unless it'll turn out to be a really long list, then a recyclerview is recommended.
Hope that helps (:
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.
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
I'm new into android and i'm dealing with the following problem. I need to create a button which groups another two buttons of similar features (sort of submenu). So let's say we have a button called "search", by clicking on it the search button should disappear and the two buttons (e.g. "google" and "bing") should be seen on the screen.
So, my idea was to manage all three buttons programmatically in the same layout instead of creating a new (temp)layout just to show and handle the two buttons. Like a state machine. More precisely it would be like this:
We press on the "search" button.
onClick(View) determines wheter we are on the main screen (mode=mainmenu), renames the search button to "google" and creates the second button named "bing", or (mode=submenu) then call the function of the button due to the search button is already renamed to "google"...
By pressing the back button onBackPressed() checks if we are in the submenu (mode=submenu) then hide the "bing" button and rename "google" to "search", otherwise we are in the main menu (mode=mainmenu), finish the activity.
Does this make sense at all? Besides this will produce lots of code with rising count of buttons and (sub)menus and worse maintainability for further changes.
Thanks!
P.S. Sorry if my english sucks (not my native language) ;-)
That's too much code and too much debugging will be needed, so I think, a better way is just creating a new layout.
Well if you have performance issues or expecting performance issues can arise (due to complexity of you GUI) then may be this make sense. But if not, code simplicity is more important than slight increase in performance.
You can create an button that remain invisible(gone, to be exact) until the "search" button is pressed, and rename the original search button. It works, and it will be easier to implement if you set up layout in xml. It also give you a preview that shows what it looks like. To show widget programmatically will have code that hard to maintain.
However, the design that change button text is not a good design. First, when the "search" is pressed, changing its text is very confusing. I personally suggest you to pop-out a selection dialog. Or just show both search button at first place, unless you really do not have place for two button.
I recently wrote my first app for android, and I created a listview for selecting an element from a list of about 500 items. Since it's basically the default listview, it's searchable, and I can bring up the onscreen keyboard by holding down the menu button, but I was wondering if there was a way to bring up the keyboard automatically (and not make it freak out if the phone has a physical keyboard). Does anyone know how I can do this? I've been searching around and haven't found anything.
Add this to your xml activity list definition (AndroidManifest.xml)
android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
Maybe not exactly what you want, nevertheless; you could add a EditText above your list. When this EditText gets focus (which it will by default when you show your activity, presuming it's the first GUI component on the layout) it will also automatically trigger the software keyboard.
The neat thing of this approach is that it gets even more intuitive for the user that he or she can actually search the list by entering a search criteria.