android 控件按下和放開後,字體顏色的改變

values/colorlist.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <color name="LeftSerchAccountTextColor">#2A67A3</color>
    <color name="LeftSerchPressAccountTextColor">#FFFFFF</color>

</resources>


程序中:

mainSearchButton.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					mainSearchImage.setTextColor(getResources().getColor(R.color.LeftSerchPressAccountTextColor));
                }else if (event.getAction() == MotionEvent.ACTION_UP) {
                	mainSearchImage.setTextColor(getResources().getColor(R.color.LeftSerchAccountTextColor));
               }
				
				return false;
			}
		});


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章