I've made a Gallery and I used a selector to show a slightly different background when an item is selected or clicked:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="false"
- android:state_selected="true"
- android:drawable="@drawable/selected"
- />
- <item android:state_pressed="true"
- android:drawable="@drawable/pressed"
- />
- <item android:drawable="@drawable/default_item"
- />
- </selector>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
So far so good, I can see the different backgrounds when I select or click on an item in the gallery.
Now I wanted to increase the size of an item when it is selected. I used the 'setOnItemSelectedListener' of the Gallery object:
Using java Syntax Highlighting
- mGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent, View v,int position, long id) {
- v.setLayoutParams(new Gallery.LayoutParams(150, 150));
- ...
- }
- }
Parsed in 0.029 seconds, using GeSHi 1.0.8.4
Now the size of an selected item in the gallery is bigger than the size of the others. But the background of this item isn't changed anymore. Can anyone tell me why this doesn't work and how I can make it work?
thanks



