Dear twinkle,
★Here is solution to change default color of GridView background base on
state of item (Focus/Unfocus/Enable/Press...etc)
❶. In xml layout of grid view:
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
<!-- Indicate we used custom selector -->
android:listSelector="@drawable/grid_selector"/>
❷. Create custom selector grid_selector.xml, with content as below:
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/selector_item">
<item
android:state_pressed="true"
android:drawable="@drawable/focus_offfocus">
</item>
<item
android:state_enabled="true"
android:state_focused="true"
android:drawable="@drawable/focus_onfocus">
</item>
<item android:state_enabled="true"
android:drawable="@drawable/focus_offfocus">
</item>
</selector>
*※Note:*
①. android:*drawable*="@drawable/focus_onfocus, in your case *drawable *replace
by* color*
②. Combined each state to set color of GridView
Regards,
DatNQ
On Wed, Feb 23, 2011 at 4:31 PM, twinkle sachdeva <
[email protected]> wrote:
> Hi all,
>
> I am using grid view widget,which on selection shows default orange color
> of android on selection.
>
> My requirement is to show another color which will be shown till the time
> item is in focus.
>
> I cannot change the background of gridview, neither changing the background
> of an item in gridview will work
>
> Please let me know,if you are aware of any solution.
>
> Cheers!!
> -Twinkle
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en