, "focusable in touch mode" true. setFocusableInTouchMode(true);, . , D .
public class CustomButton extends View
{
...
public CustomButton(Context context, Car car)
{
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
setBackgroundColor(Color.BLACK);
setOnClickListener(listenerAdapter);
setClickable(true);
}
@Override
protected void onFocusChanged(boolean gainFocus, int direction,
Rect previouslyFocusedRect)
{
if (gainFocus == true)
{
this.setBackgroundColor(Color.rgb(255, 165, 0));
}
else
{
this.setBackgroundColor(Color.BLACK);
}
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
}
...
}