프로그래밍 정리/안드로이드

[Android - 안드로이드] 자바 소스에서 상황에 따른 Color값 변경(presee, check.. 등등)

주누다 2015. 4. 14. 17:28
반응형

int[][] states = new int[][] {

//    new int[] { android.R.attr.state_enabled}, // enabled

//    new int[] {-android.R.attr.state_enabled}, // disabled

//    new int[] {-android.R.attr.state_checked}, // unchecked

   new int[] { android.R.attr.state_pressed},  // pressed

   new int[] {}

};


int[] colors = new int[] {

   Color.parseColor( ("#" + cRowNor) ),

   Color.parseColor( ("#" + cRowSel) )

};

ColorStateList c = new ColorStateList(states, colors);

vh.name.setTextColor(c);


이런 형식으로 넣으면 됨

cRowNor, cRowSel은 값이 "847191", "283712" 이런 형식으로 되어 있어 "#" 붙임.


참조 : http://stackoverflow.com/questions/15543186/colorstatelist-android-programatically

반응형