點擊監聽器我有一個imageview的 - 它有兩個屬性 - 可聚焦和focusableintouchmode設置爲真正
Android的焦點監聽和關於ImageView的
<ImageView
android:id="@+id/ivMenu01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="true"
android:focusableInTouchMode="true" >
</ImageView>
我已經實現了onFocusChangeListener在我的動態 -
@Override
public void onFocusChange(View v, boolean hasFocus) {
switch (v.getId()) {
case R.id.ivMenu01:
if (hasFocus) {
ivMenu01.setImageBitmap(Utility
.getBitmap("Home_ford_focus.png")); // Focussed image
} else {
ivMenu01.setImageBitmap(Utility.getBitmap("Home_ford.png")); // Normal image
}
break;
default:
break;
}
}
另外,onClickListener -
case R.id.ivMenu01:
ivMenu01.requestFocus();
Intent iFord = new Intent(HomeScreen.this, FordHome.class);
startActivity(iFord);
break;
現在,當我點擊ImageView的第一次點擊使焦點轉移到ImageView的第二次單擊執行的操作。 我不知道爲什麼會發生這種情況。
第一次點擊應該請求焦點以及執行操作。
任何有關如何做到這一點的幫助將不勝感激。
感謝您的回答。 – Anukool 2013-02-12 13:31:09