if I click on a listview item i want to keep the highlight on it. how do i do this?
Use ListView.setChoiceMode(). The "highlight" is meant to disappear when the user touches the screen and trying to change this behavior would be bad for consistency. The choice mode was meant to address this.
Related
I have an activity which one of its components is a EditText. The goal of it is the following: when user clicks/taps on it, another activity is called to select some items (categories). I have implemented it using an activity that extends listactivity and using a custom adapter to paint custom rows for items.
All is ok, but I guess if using a EditText is the best option. The problem using this kind of control is that when user clicks/taps on it, the virtual keyboard appears and I do not want it to appear. If I use a TextView instead, virtual keyboard does not appear, but it is not clear for user that he have to click/tap on it to select a category (as the underscore line is not shown here as when using EditText).
So what android widget is the best to use in this scenario?
You can always use expandable list view there are many examples online that could help u to create it much more flexible than a spinner and it looks elegant and easy to use, it also show the user directly what is used for by just giving it a look and u can always customize it and play with its look and functionality.
Sounds like you are looking for a Spinner? That way you wouldn't have to load up a separate Activity to make the category selection. Otherwise, why not just use a Button? It's obviously clickable, that's for sure!
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!
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.
I'm looking for suggestions on how to go about adding a ListView selector that is 'permanent'. By this, I mean a single row in the ListView is always highlighted; it should move up or down in reponse to any D-pad presses (i.e. like the default selector) but also remain set/highlighted if the user were to scroll the ListView in either direction (i.e. it's still highlighted even when it's off-screen).
I've looked at using the standard selector mechanism, but am unable to get the selector to remain in place if the ListView is touched (and thus scrolled), so it makes me think that this isn't the best option? Perhaps there's a <selector> "state_*" that I've ignored?
The other option would be to use the onItemSelected() callback, but at first look this appears more convoluted?
Any suggestions/recommendations/experiences gratefully receieved.
Cheers
James
I'm looking for suggestions on how to go about adding a ListView selector that is 'permanent'.
Please do not do this. There is no selection in touch mode, and that is by design. As suggested in this article, "Use the appropriate feature if you need persistent selection (radio button, check box, the ListView choice mode, etc.). Do not try to keep the focus or selection in touch mode."
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.