When scroll in listview selected item background colr disappear?

I am implementing a list . There are number of items in it, when i select a item from list set a color for list item. when i scroll the list view it disappear.

what may be reason ? Code for adapter is given as below:

  public class CustomListViewAdapterProduct extends
        ArrayAdapter<HashMap<String, Object>> 

    Context context;
    public CustomListViewAdapterProduct(Context context, int resourceId,
            ArrayList<HashMap<String, Object>> Strings) {
        super(context, resourceId, Strings);
        this.context = context;

    /* private view holder class */

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        LayoutInflater mInflater = (LayoutInflater) context

    if (convertView == null) {

      convertView = mInflater.inflate(R.layout.list_item_detail, null);
     holder = new ViewHolder();
     holder.txtProduct = (TextView) convertView.findViewById(R.id.product);
     holder.txtCode = (TextView) convertView.findViewById(R.id.code);
     convertView.setBackgroundResource((position % 2) == 0 ? R.color.light
                            : R.color.dark);

        } else {
            if (position == selectedPosition) {
            } else {
                        .setBackgroundResource((position % 2) == 0 ? R.color.light
                                : R.color.dark);

            holder = (ViewHolder) convertView.getTag();



        return convertView;


In the past when I have display issues with a ListView it's usually because I forgot to set the cachColorHint. See this post for more information.

Need Your Help

Ember Data hasMany foreach within controller

ember.js controller ember-data

I currently have the following models setup using Ember Data and the Local storage adaptor.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.