views:

49

answers:

1

I am using gallery widget i want to change selected image.

@Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    if(lastSeen != null){
       lastSeen.setImageResource(unselected image);
    }

    (ImageView(view)).setImageResource(selected image)
    lastSeen = view;
}

When i run the following code and i use roller ball or arrow keys over device and if i try to scroll left to right or right to left focus goes out of gallery to next item over the screen what is that ?

A: 

able to fix it by myself.

created xml item xlml file

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
        <item  android:state_selected="true" 
                        android:drawable="@drawable/slider_se_icon_1101"/>
        <item android:drawable="@drawable/slider_un_icon_1101" />
</selector>

make sure selected and unselected images having same height and width else it will not work.

Faisal khan