title: How to give color for listview in android
body: <p>i am having a list view in which i would like to give a background color to a row when it is pressed.When i select an item its changing the color but the problem is when i scroll down other rows too are got colored.I don't want that.</p>
  
  <p>Here is my code:
   Thanks in advance</p>
  
  <p>listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {</p>
  
  <pre><code>          @Override
            public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                int position, long id) {
                final String item = (String) parent.getItemAtPosition(position); 
                    Toast.makeText(getBaseContext(), item, Toast.LENGTH_LONG).show();
                    view=parent.getChildAt(position);
                    view.setBackgroundColor(Color.GREEN);
  
            }
            });
  
  }
  </code></pre>