The best way to do that is to use a StateListDrawable: http://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html
That's what I did with "AppSwipe!" on the Android Market. The selected item has a blue background with a gradient. Everything else in the list has a transparent background. Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Fri, May 13, 2011 at 2:07 PM, gaurav gupta <[email protected]>wrote: > Hi , > thanks 4 reply > Now m setting ID for every imageview that m creating dynamically like > * > > int > * > > imageview_id=10000; > > *for*(*int* i=0;i<tracks.size();i++) > > { > > imgview_layout=(LinearLayout)findViewById(R.id.*sub_layout*); > > imageview=*new* ImageView(HotelViewScreen.*this*); > > imageview.setImageResource(R.drawable.*gray_dot*); > > imageview.setId(imageview_id+i); > > imageview.setPadding(5, 2, 5, 2); > > imgview_layout.addView(imageview); > > } > > its give me id for every imageview . Now in My OnItemSelectedListener m > using this Id like that: > > > > hotels_gallery > > .setOnItemSelectedListener(*new* OnItemSelectedListener() { > > @Override > > *public* *void* onItemSelected(AdapterView<?> arg0, View arg1, > > *int* position, *long* arg3) { > > // *TODO* Auto-generated method stub > > //Toast.makeText(HotelViewScreen.this, ""+arg2, Toast.LENGTH_LONG).show(); > > hotelName=tracks.get(position).getHotelName(); > > hotelCity=tracks.get(position).getHotelCity(); > > hotelname.setText(hotelName+","+Html.*fromHtml*("<font color ='blue'>"+ > hotelCity+"</font>")); > > *int* image_id=imgview_layout.getChildAt(position).getId(); > > ImageView abc=(ImageView)findViewById(image_id); > > abc.setImageResource(R.drawable.*yellow_dot*); > > } > > @Override > > *public* *void* onNothingSelected(AdapterView<?> arg0) { > > // *TODO* Auto-generated method stub > > } > > }); > > Now i can change the Image src everytime on OnSelectedListener. > Now every selected gallery item's indicator image is becoming yellow . > my requirement is that i need only selected gallery item's image should to > change. > rest of all indicator will gray ,selected gallery item will be yellow. > > > > On Sat, May 14, 2011 at 1:23 AM, ashutoshmimani > <[email protected]>wrote: > >> Can you not save references to your image views when you are creating >> them? >> >> On May 13, 3:34 pm, gaurav gupta <[email protected]> wrote: >> > hi justin >> > i want to just change my textview and imageview with gallery. >> > my imageview showing the current position of gallery . like if gallery's >> > currenit position is 2 , the 2nd imageview will be yellow,now it is >> gray >> > its just like a indicator in footer that will show the postion of >> gallery's >> > selected image. >> > >> > On Sat, May 14, 2011 at 12:58 AM, Justin Anderson < >> [email protected]>wrote: >> > >> > >> > >> > >> > >> > >> > >> > > I'm not entirely sure what you are trying to accomplish... >> > >> > > Thanks, >> > > Justin Anderson >> > > MagouyaWare Developer >> > >http://sites.google.com/site/magouyareware >> > >> > > On Fri, May 13, 2011 at 1:23 PM, gaurav gupta < >> [email protected]>wrote: >> > >> > >> HI , >> > >> i have a new issue , my using small dots to show the current image >> > >> position of a gallery. >> > >> these images are creating in runtime using this code >> > >> > >> for (*int* i=0;i<tracks.size();i++) >> > >> > >> { >> > >> > >> LinearLayout >> imgview_layout=(LinearLayout)findViewById(R.id.*sub_layout* >> > >> ); >> > >> > >> ImageView imageview=*new* ImageView(HotelViewScreen.*this*); >> > >> > >> imageview.setImageResource(R.drawable.*gray_dot*); >> > >> > >> imageview.setPadding(5, 2, 5, 2); >> > >> > >> imgview_layout.addView(imageview); >> > >> > >> } >> > >> > >> Now i need that i have to change this imageview's Src everytime when >> > >> gallery's Selected item will change. >> > >> > >> should i set id for every imageview?? >> > >> > >> Suggest me. >> > >> > >> Thnks >> > >> > >> On Sat, May 14, 2011 at 12:42 AM, gaurav gupta < >> [email protected] >> > >> > wrote: >> > >> > >>> Thanks Justin >> > >>> Its works , >> > >>> :) >> > >> > >>> On Sat, May 14, 2011 at 12:32 AM, Justin Anderson < >> [email protected] >> > >>> > wrote: >> > >> > >>>> The way I did it in AppSwipe! was with a RelativeLayout that >> contains a >> > >>>> Gallery and a TextView. I used an OnItemSelectedListener to change >> the text >> > >>>> displayed in the text view. >> > >> > >>>> >> http://developer.android.com/reference/android/widget/AdapterView.OnI... >> > >> > >>>> It is pretty straightforward once you get the design figured out... >> > >> > >>>> Thanks, >> > >>>> Justin Anderson >> > >>>> MagouyaWare Developer >> > >>>>http://sites.google.com/site/magouyaware >> > >> > >>>> On Fri, May 13, 2011 at 12:56 PM, gaurav gupta < >> > >>>> [email protected]> wrote: >> > >> > >>>>> Hti guys >> > >>>>> m making a gallery that contain 10 images , each images have a >> > >>>>> different name . i want that if i scroll the gallery , selected or >> focused >> > >>>>> image's name should be appear. >> > >>>>> Name should change on onFoucs or OnItemSelected. >> > >>>>> Suggest me. >> > >>>>> Thanks in advance. >> > >> > >>>>> -- >> > >>>>> 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 >> > >> > >> -- >> > >> 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 >> >> -- >> 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 > -- 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

