2011-08-24 64 views
2

我需要更改列表視圖中被手指點擊時的背景顏色。 例如:我有5/6行的列表視圖;我需要在一行上點擊一下,它的背景顏色變成綠色(選中)。點擊所選行後,背景變成黑色。點擊更改列表視圖行背景

我該怎麼做?

謝謝

+0

請,如果你想要一個答案命名目標平臺... – cprogrammer

回答

3
public View getView(final int position, View convertView,ViewGroup parent) { 
     ViewHolder holder; 

     if (convertView == null) 
     { 
      convertView.setTag(holder); 
     }  
     else { 
       holder = (ViewHolder) convertView.getTag(); 
     } 
     if(position == your selected row position) 
     { 
      convertView.setBackgroundColor(Color.YELLOW); 
     } 

     return convertView; 

    }