try:
if(position ==0)
row.setBackgroundColor(Color.CYAN);
else
row.setBackgroundColor(Color.BLACK);
getView will sometimes return a view that was scrolled off the screen
rather than creating a new one.
On Jan 13, 4:17 pm, Alx <[email protected]> wrote:
> Hi there
>
> When I'm trying to set the background colour of the listitem with, say
> position 0 the colour is repeated when I scroll through the listview.
>
> My code is
>
> class CustomAdapter extends SimpleCursorAdapter {
>
> public CustomAdapter(Activity context, int task_row, Cursor
> tasks2,
> String[] from, int[] to) {
> super(context , task_row,tasks2, from, to);
>
> }
>
> @Override
> public View getView(int position, View convertView, ViewGroup
> parent) {
> View row = super.getView(position, convertView,
> parent);
>
> if(position ==0)
> {
> row.setBackgroundColor(Color.CYAN ) ;
> }
> ...
>
> Any suggestions?
>
> Cheers
>
> Alx
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---