List view Position in adapter
<p>I want to identify a new row added in my listview with a unique background image and the old record takes the default background. I am using a listadaper, how can I achieve this ?</p>

<p>Part of my code is as follows:</p>

<pre><code>if(position==0){
    holder.row.setBackgroundResource(R.drawable.layer_selected);
    holder.text.setTextColor(Color.BLACK);
} else if(position&gt;0){
    holder.row.setBackgroundResource(R.drawable.layer_unselected);
    holder.text.setTextColor(Color.WHITE);
}





 public View getView(final int position, View convertView, ViewGroup parent) {[

        final ViewHolder holder;[

        if (convertView==null) {

            convertView=newView(position, parent);

            holder = new ViewHolder();

            holder.remove=(ImageView)convertView.findViewById(R.id.remove);

            holder.row=(ImageView)convertView.findViewById(R.id.row);

            holder.text=(TextView)convertView.findViewById(R.id.text);

            holder.layer=
(RelativeLayout)convertView.findViewById(R.id.layer);

            convertView.setTag(holder);

        } else {

            holder = (ViewHolder) convertView.getTag();
        }

        holder.text.setText(String.valueOf(position+1));


        holder.remove.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                System.out.println("position remove: "+ position+1);

                main.removeItem(position+1);

            }

        });


        if(position+1&gt;main.items.size()-1)
        {
           holder.row.setBackgroundResource(R.drawable.layer_unselected);

           holder.text.setTextColor(Color.WHITE);
        }


        pos = position+1;

        holder.row.setOnClickListener(new OnClickListener() {

            @Override

            public void onClick(View v) {

                main.selectItem(position+1);

                   holder.row.setBackgroundResource(R.drawable.layer_selected);

holder.text.setTextColor(Color.BLACK);


            }
        });

        return(convertView);
    }


    private View newView(int position, ViewGroup parent) {
        return(main.getLayoutInflater().inflate(R.layout.layer_row, parent, false));
    }

    class ViewHolder {
        ImageView remove, row;
        TextView text;
        RelativeLayout layer;
    }
</code></pre>

<p>where "row" is my ImageView and "text" is a text centered on the imageview.</p>
