I defined this selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/backarrow_blueshiny" />
<item android:state_focused="true"
android:drawable="@drawable/backarrow_blackshiny" />
<item android:drawable="@drawable/backarrow_blackshiny" />
</selector>
and it is used with this button:
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bottomborder_glossy">
<ImageButton
android:id="@+id/filter_button_back"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:src="@drawable/selector_back_button"
android:background="#00000000"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
and the onTouch event consists of:
public boolean onTouch(View v, MotionEvent event)
{
final int actionPerformed = event.getAction();
final int widgetID = v.getId();
if (actionPerformed == MotionEvent.ACTION_UP)
{
switch (widgetID)
{
case R.id.filter_button_back:
{
this.finish();
break;
}
}
}
return false;
}
what this button does is to exit the current activity. this.finish()
However, when testing the button does not always switch to "backarrow_blueshiny", namely when pressed very quickly.
So the problem is that the selector fires more slowly than the onTouch event (MotionEvent.ACTION_UP).
Is there anything I can do to make sure the selector is not "laggy"?
source
share