private int getTextColor ( int item ) { int scrollX = getScrollX ( ) ; // set color of text int color = textColor . getDefaultColor ( ) ; int itemWithPadding = ( int ) ( itemWidth + dividerSize ) ; if ( scrollX > itemWithPadding * item - itemWithPadding / 2 && scrollX < itemWithPadding * ( item + 1 ) - itemWithPadding / 2 ) { int position = scrollX - itemWithPadding / 2 ; color = getColor ( position , item ) ; } else if ( item == pressedItem ) { color = textColor . getColorForState ( new int [ ] { android . R . attr . state_pressed } , color ) ; } return color ; }
Calculates text color for specified item based on its position and state .