Merge change 21540 into eclair

* changes:
  Fix listview clicks with the trackball.
This commit is contained in:
Android (Google) Code Review
2009-08-17 13:00:26 -07:00

View File

@@ -546,6 +546,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
private void initAbsListView() { private void initAbsListView() {
// Setting focusable in touch mode will set the focusable property to true // Setting focusable in touch mode will set the focusable property to true
setClickable(true);
setFocusableInTouchMode(true); setFocusableInTouchMode(true);
setWillNotDraw(false); setWillNotDraw(false);
setAlwaysDrawnWithCacheEnabled(false); setAlwaysDrawnWithCacheEnabled(false);
@@ -1433,6 +1434,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* this is a long press. * this is a long press.
*/ */
void keyPressed() { void keyPressed() {
if (!isEnabled() || !isClickable()) {
return;
}
Drawable selector = mSelector; Drawable selector = mSelector;
Rect selectorRect = mSelectorRect; Rect selectorRect = mSelectorRect;
if (selector != null && (isFocused() || touchModeDrawsInPressedState()) if (selector != null && (isFocused() || touchModeDrawsInPressedState())
@@ -1450,8 +1455,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
Drawable d = selector.getCurrent(); Drawable d = selector.getCurrent();
if (d != null && d instanceof TransitionDrawable) { if (d != null && d instanceof TransitionDrawable) {
if (longClickable) { if (longClickable) {
((TransitionDrawable) d).startTransition(ViewConfiguration ((TransitionDrawable) d).startTransition(
.getLongPressTimeout()); ViewConfiguration.getLongPressTimeout());
} else { } else {
((TransitionDrawable) d).resetTransition(); ((TransitionDrawable) d).resetTransition();
} }
@@ -1731,6 +1736,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
return false; return false;
} }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return false;
}
@Override @Override
public boolean onKeyUp(int keyCode, KeyEvent event) { public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode) { switch (keyCode) {
@@ -1739,8 +1749,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (!isEnabled()) { if (!isEnabled()) {
return true; return true;
} }
// Long clickable items don't necessarily have to be clickable if (isClickable() && isPressed() &&
if (isClickable() && (event.getRepeatCount() == 0) && isPressed() &&
mSelectedPosition >= 0 && mAdapter != null && mSelectedPosition >= 0 && mAdapter != null &&
mSelectedPosition < mAdapter.getCount()) { mSelectedPosition < mAdapter.getCount()) {