之前在射擊:選擇反應慢 - 有時不是所有的首發我有這樣的選擇定義的下一個活動
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- PRESSED -->
<item android:state_pressed="true"
android:drawable="@drawable/backarrow_blueshiny" />
<!-- FOCUSED -->
<item android:state_focused="true"
android:drawable="@drawable/backarrow_blackshiny" />
<!-- DEFAULT -->
<item android:drawable="@drawable/backarrow_blackshiny" />
</selector>
,並與該按鈕使用:
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bottomborder_glossy">
<!-- BACK -->
<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>
和onTouch事件包括:
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;
}
此按鈕所做的是退出當前活動this.finish()
但是,在我的測試中,按鈕並不總是切換到「backarrow_blueshiny」 - 即按壓得非常快。
所以問題在於選擇器的觸發速度比onTouch(MotionEvent.ACTION_UP)事件慢。
有什麼我可以做的,以確保選擇不是「laggy」?
有趣的想法,我會盡快嘗試... – 2011-05-26 19:41:15
你建議的方法似乎有同樣的反應速度,我已經得到。我仍然可以推得很快,UI不會反應,但ACTION_UP事件已經觸發。 – 2011-05-26 20:23:04
我會將你的回答標記爲答案,因爲它似乎不太可能得到更多答案 – 2011-05-26 22:34:00