Re: [android-developers] List view row background.
I have another issue that I'm facing. I have registered for a callback on item click. Whenever I click on a row, it remains selected. I want to clear the selection. How do I do it? I tried various functions, but none of them worked. On Monday, April 9, 2012 4:01:43 PM UTC+5:30, Put_tiMe wrote: > Ok, I kind of got it together. > > For the row, I'm setting the background to my bitmap image. > For selection, I'm setting the ListView attribute: > android:listSelector="@drawable/xxx" > > > It kind of works. But I can't see the selection. > i.e. when a row is selected (or clicked) I don't see the color change. > This happens when I set the background for the rows. > > To counter that I tried setting this attr: android:drawSelectorOnTop="true" > > But the problem with that is that the row contents are completely hidden. > > What should I do in this case? > > > > On Monday, April 9, 2012 3:39:13 PM UTC+5:30, Put_tiMe wrote: > >> I also need to change the drawable when a listview item is selected. >> >> How can I achieve this? >> >> On Monday, April 9, 2012 2:19:39 PM UTC+5:30, bin yang wrote: >> >>> Define common list item layout file. >>> Using LayoutInflater to create view of Adpater. >>> >>> 在 2012年4月9日 下午4:30,Put_tiMe 写道: >>> I want to add a background image for each row of a list-view control. I have written a custom adapter for the list view. What is the best way of doing it? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] List view row background.
Ok, I kind of got it together. For the row, I'm setting the background to my bitmap image. For selection, I'm setting the ListView attribute: android:listSelector="@drawable/xxx" It kind of works. But I can't see the selection. i.e. when a row is selected (or clicked) I don't see the color change. This happens when I set the background for the rows. To counter that I tried setting this attr: android:drawSelectorOnTop="true" But the problem with that is that the row contents are completely hidden. What should I do in this case? On Monday, April 9, 2012 3:39:13 PM UTC+5:30, Put_tiMe wrote: > I also need to change the drawable when a listview item is selected. > > How can I achieve this? > > On Monday, April 9, 2012 2:19:39 PM UTC+5:30, bin yang wrote: > >> Define common list item layout file. >> Using LayoutInflater to create view of Adpater. >> >> 在 2012年4月9日 下午4:30,Put_tiMe 写道: >> >>> I want to add a background image for each row of a list-view control. >>> I have written a custom adapter for the list view. >>> >>> What is the best way of doing it? >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To post to this group, send email to android-developers@googlegroups.com >>> To unsubscribe from this group, send email to >>> android-developers+unsubscr...@googlegroups.com >>> 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] List view row background.
I also need to change the drawable when a listview item is selected. How can I achieve this? On Monday, April 9, 2012 2:19:39 PM UTC+5:30, bin yang wrote: > Define common list item layout file. > Using LayoutInflater to create view of Adpater. > > 在 2012年4月9日 下午4:30,Put_tiMe 写道: > >> I want to add a background image for each row of a list-view control. >> I have written a custom adapter for the list view. >> >> What is the best way of doing it? >> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] List view row background.
In the getView method of the adapter, use the index of the row to set background to. Suppose every row is a textView, then textView.setBackgroundColor(Color.BLACK) would do the trick. For different indices, you could do this... public View getView(int index, View convertView, ViewGroup parent) { textView.setText() ... ... if(index %2 == 0){ textView.setBackgroundColor(Color.BLACK); }else{ textView.setBackgroundColor(Color.BLUE); } return textView; } Something like that I guess is what you are looking for. Hope that helps On Mon, Apr 9, 2012 at 1:30 PM, Put_tiMe wrote: > I want to add a background image for each row of a list-view control. > I have written a custom adapter for the list view. > > What is the best way of doing it? > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] List view row background.
Define common list item layout file. Using LayoutInflater to create view of Adpater. 在 2012年4月9日 下午4:30,Put_tiMe 写道: > I want to add a background image for each row of a list-view control. > I have written a custom adapter for the list view. > > What is the best way of doing it? > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] List view row background.
I want to add a background image for each row of a list-view control. I have written a custom adapter for the list view. What is the best way of doing it? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en