Android :: ListView Selector Color ?
Jan 10, 2010
I have 2 questions regarding a ListView in Android:
How can I get the color of the listview's focused row ? I tried to use the ListView.getSelector() method, which according to its documentation should give me what I'm looking for, but it's giving me a Drawable object which I don't know how to retrieve the color from (if possible...).
How can I set the color of the listview's focused row ? Here I tried to use the setSelector() method on the listview, passing it a ColorDrawable object, but the result of doing it is that the whole background of the list view is painted in that color... and this is not what I wanted of course...
View 2 Replies
Aug 28, 2010
I'm attempting to change the background color of an Android TextView widget when the user touches it. I've created a selector for that purpose, which is stored in res/color/selector.xml and roughly looks like that:
CODE:................
The clickable attribute of the TextView is "true", in case that's of interest.
When I assign this selector to a TextView as android:background="@color/selector",
I'm getting the following exception at runtime: ERROR/AndroidRuntime(13130): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #6: <item> tag requires a 'drawable' attribute or child tag defining a drawable
When I change the attribute to drawable, it works, but the result is looking completely wrong because the IDs appear to be interpreted as image references instead of color references (as the "drawable" suggests).
What confuses me is that I can set a color reference, e.g. "@color/black", as the background attribute directly. This is working as expected. Using selectors doesn't work.
I can also use the selector as the textColor without problems.
What's the correct way to apply a background-color-selector to a TextView in Android?
View 2 Replies
View Related
Sep 21, 2010
I'm trying to use a color defined in a stlyle in a selector but it is causing a Resources$NotFoundException.
First I added a new attribute to attr.xml:
CODE:..........
Then I defined that attr value in styles.xml:
CODE:..........
Then I tried to use that attr in my selector definition:
CODE:................
Lastly, the activity uses the ThemeNoTitleBar style theme in the manifest.
I've also tried creating a color in colors.xml and having it use the new attr but that also fails.
I'm obviously missing something but am not sure what to do to fix it. My intent is to create multiple themes and have the selector use the color in the currently selected theme.
View 1 Replies
View Related
Jul 22, 2010
I specified a selector drawable for the background of a layout as below, so when user clicks on the layout, the layout will have a different background. But, I didn't specify color selector for the TextViews in the layout, because there are many TextViews with different colors and I am too lazy to define color selector for them. So the text color keeps the same when the layout is clicked. My questions is, is there an automatic way to specify that the text color is highlighted/changed when the layout is clicked, so I don't have to define color selector for each of the TextViews in a layout?
View 1 Replies
View Related
Sep 28, 2010
I have created a ListView and applied a selector to it as follows
CODE:..............
When focussed or pressed, the background of the ListView item comes as specified in the selector. But the default background is never applied, can you tell me what is wrong?
By the way, this is the customised row xml I've used:
CODE:...................
View 2 Replies
View Related
Aug 30, 2010
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 received.
View 1 Replies
View Related
Aug 8, 2010
The layout xml is as below. I have a RelativeLayout, which contains a TextView. The OnClick listener is set on RelativeLayout. The RelativeLayout has a selector background. What I want is, when user clicks on the RelativeLayout, the background of the RelativeLayout should change, and the color of the text of the TextView should change too. Even though I set color selector for the TextView, only the selector on RelativeLayout works. The color selector on TextView doesn't work. How can I implement change of both RelativeLayout background and text color of TextView when user clicks the layout?
CODE:...................
View 2 Replies
View Related
Mar 5, 2010
I have a listview with a custom item_row.xml. I've defined a selector in this way:
CODE:................
And then put into item_row.xml in this way:
CODE:...................
I want 2 things:
When i move with arrow keys, the item selected changed its background. It's works fine with the actual implementation of selector.
When i press a item, the item changed its background too, but it doesn't work with the actual selector.
I try to set also into the ListView android:listSelector="@drawable/list_selector" but it doesn't work neither.
View 1 Replies
View Related
Apr 28, 2010
I am trying to style my ListView with two 9-patch background images (16px * 9px), one dark image for default state and another green image for selected and pressed state.
It works except for just one problem that when I select or press one list item, it seems that the selected item overlap the next one a little bit as I can see some pixels of the green background image is on the top of next item.
View 1 Replies
View Related
Sep 18, 2010
Trying to get an Android ListView to do what I want.
I want to have a ListView in single choice mode with a custom row layout that has a different background color for selected, pressed and checked (i.e. the choice is shown by a color rather than a check mark - this is what I would normally call the "selection" but selection in android seems line I'm about to choose before I press it)
I thought of trying a background selector with the three states in it. It works fine for state_selected and state_pressed, but not state_checked. So I created a CheckableRelativeLayout that extends RelativeLayout and implements Checkable and used for the view of each row.
A simplified version is shown here:
CODE:.....
bkg_selector looks like
CODE:..............
The colors are defined elsewhere.
This still didn't work. So in the custom ListAdapter I tracked the "checked" row and tried (in getView) if( position == checkedPosition ) ret.getBackground().setState(CHECKED_STATE_SET);
And it STILL doesn't work. How can I get it to do what I want?
View 1 Replies
View Related
Sep 27, 2010
I have a ListView. When I click on a ListItem, I set the background of the ListItem (it's view) to another color:
CODE:........
Here is my adapter:
CODE:......
The problem is, if I select multiple rows, then multiple rows have a colored background. I only want the clicked item to have a colored background. So if I click on row 2, I want it to turn red, then if I click row 1, I want row 2 to go back to normal, and row 1 to turn red.
View 2 Replies
View Related
Apr 1, 2010
Is it possible to apply a custom background to each Listview item via the list selector?
The default selector specifies @android:color/transparent for the state_focused="false" case, but changing this to some custom drawable doesn't affect items that aren't selected. Romain Guy seems to suggest in this answer that this is possible.
I'm currently achieving the same affect by using a custom background on each view and hiding it when the item is selected/focused/whatever so the selector is shown, but it'd be more elegant to have this all defined in one place.
For reference, this is the selector I'm using to try and get this working:
CODE:...............
And this is how I'm setting the selector:
CODE:.........................
View 3 Replies
View Related
Nov 3, 2010
Look for examples where ListViews can show multiple view types.
View 6 Replies
View Related
Apr 23, 2010
How to do a listview which looks like this? I'm interesting in the style of rows with an own background and the selector working fine.
View 1 Replies
View Related
Jun 17, 2010
I need to set alternate color in list view rows but when i do that it removes/ disables the on focus default yellow background
I tried with backgroundColor
rowView.setBackgroundColor(SOME COLOR);
also with backgrounddrwable.
CODE:.........
But it wont work. is there any way we can set background color and on focus color simultaneously which will work.
View 1 Replies
View Related
Jul 13, 2009
I have an expandable list with a custom adapter. Everything works great but there are two problems.
First whenever a group or child has a custom background color set the orange selector does not show up. If I dont setup a color the selector draws nicely and also the fade away for context menus works.
Second, some of my text inside a list item is linkified. Whenever a link is present the selector does not draw again. It seems that the click event is handled by the internal link view instead of propagating to the list view.
View 4 Replies
View Related
Oct 20, 2009
How do I get a box appear in a different color listview practically the first field is the title.
View 2 Replies
View Related
Nov 3, 2009
I want to set the background color of ListView as white.I tried this:
getListView().setBackgroundColor(color.white); getListView().setCacheColorHint(color.transparent);
But it doesnt change the color.What should I do?
View 2 Replies
View Related
Jul 26, 2010
Is there any way to set the background color of a ListView header? I've tried calling setBackgroundColor on the header view, and I've tried android:colorBackground in the xml.
Also what exactly is the difference between a ListView header and a standard item in the list. I notice that by default a header can be selected, which makes me think there is no difference.
View 4 Replies
View Related
Oct 29, 2010
I want to give the effect that the ListView has faded from whatever is around it. By default it is set to whatever colour your ListView is. I can adjust the orientation of the FadingEdge and the size of the FadingEdge but not the colour. Is it possible?
View 1 Replies
View Related
Aug 24, 2010
I am trying to apply a selector to a ListView to make it easy for those without touch screens to navigate my app. The thing is, by applying the selector to the ListView, it only seems to apply the background colors to the entire list, not the items inside of it. Code...
View 2 Replies
View Related
Apr 24, 2010
I have a couple of list views, one uses TextViews laid out with xml, the other uses a custom class derived from View. The default halloween color scheme is pretty ugly. How can I change the background and selection colors for the list elements. Ideally, I'd like to be able to do this in code not xml, to handle the custom view.
View 1 Replies
View Related
Aug 7, 2009
i have a listview with a very white layout. Thus I wish the fading edge was black, instead of white as it is right now. How can I change this? As far as I can see it cant be done in xml.
View 2 Replies
View Related
Apr 30, 2010
I am adding listview programmatically. My code is as follow.
CODE:..........
Now i want to change the size and color of text.
[there is know method like lv.settextsize / lv.settextcolor ]
View 6 Replies
View Related
Sep 11, 2009
I populate ListView Using ArrayAdapter, constraint: each item Text in ListView represting some actions, and each action (Item text in ListView) represent its individual color. problem: i cant change the color of each item text in ListView, according to supplied color formula. using ListView thanks i am waiting ur reply?
View 2 Replies
View Related
Oct 14, 2009
How do I change the original orange highlight color to something else? That is, the color I get when I click in a ListView.
I've tried to set the android:textColorHighlight of the ListView and/or the TextView for the rows, nothing work.
I've manage to remove it by setting android:listSelector="#00000000" of my ListView but I just want to change the color, but it seems impossible.
View 5 Replies
View Related
Sep 23, 2010
I have defined a custom theme, where I am drawing a dark gradient on my window background. My ListView background is set to be transparent, however whenever I scroll, the background color turns black, and then after scrolling has stopped, goes back to the gradient color. Why is this?
CODE:.....................................
View 1 Replies
View Related
Mar 8, 2010
My list view is a multiple selection list view. i have to show the selected list view items in one color(say green) and the other items in some other color(red). How to achieve this?
View 3 Replies
View Related
Feb 7, 2010
How can I change background color of ListView items on a pair-item basis. When I use android:backgroundColor in the ListView item layout I can achieve this, however the list selector is no longer visible. I can make the selector visible again by setting drawSelectorOnTop to true but then the selector overlays the whole item.
Any ideas how to change those background colors and keep the selector?
I would rather not change the selector itself.
Authors of GMail application have managed to achieve exactly this so it's definitely possible.
View 5 Replies
View Related
Nov 20, 2010
I have a list View in my app (this is the xml layout):
CODE:.............
Each item of my list View is composed of two TextView:
CODE:.............
I would like to change background color (and text color) of each item of my ListView on focus (and, if possibile on selection). How can i do it?
View 6 Replies
View Related