押すと緑色になり、キーを押すと再び赤色になるボタンの作り方。
1 に答える
1
@Override
public boolean onTouch(final View view, MotionEvent event) {
final int action = event.getAction();
if(view.getId()==R.id.yourButton){
if(action == MotionEvent.ACTION_DOWN)
yourButton.setBackgroundResource(R.drawable.ic_button_green);
if(action == MotionEvent.ACTION_UP)
yourButton.setBackgroundResource(R.drawable.ic_button_red);
}
}
于 2012-08-16T15:38:12.757 に答える