From: Reimar Döffinger Date: Sun, 13 Nov 2016 22:58:42 +0000 (+0100) Subject: Fix OnItemClick when using keyboard navigation. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=243cc13687c837e21016d99af70159d6501f00ed Fix OnItemClick when using keyboard navigation. --- diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index 6dc95c6..6366812 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -421,7 +421,15 @@ public class DictionaryActivity extends ActionBarActivity { } Log.d(LOG, "Loading index " + indexIndex); index = dictionary.indices.get(indexIndex); + getListView().setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); getListView().setEmptyView(findViewById(android.R.id.empty)); + getListView().setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int row, long id) { + onListItemClick(getListView(), view, row, id); + } + }); + setListAdapter(new IndexAdapter(index)); // Pre-load the collators. @@ -544,13 +552,6 @@ public class DictionaryActivity extends ActionBarActivity { ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); customSearchView.setLayoutParams(layoutParams); - listView.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int row, long id) { - onListItemClick(getListView(), view, row, id); - } - }); - languageButton = new ImageButton(customSearchView.getContext()); languageButton.setId(R.id.languageButton); languageButton.setScaleType(ScaleType.FIT_CENTER); @@ -1569,7 +1570,7 @@ public class DictionaryActivity extends ActionBarActivity { // http://groups.google.com/group/android-developers/browse_thread/thread/3d96af1530a7d62a?pli=1 result.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); result.setClickable(true); - result.setFocusable(true); + result.setFocusable(false); result.setLongClickable(true); // result.setBackgroundResource(android.R.drawable.menuitem_background); @@ -1646,6 +1647,7 @@ public class DictionaryActivity extends ActionBarActivity { } }); } + result.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); return result; }