]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Fix OnItemClick when using keyboard navigation.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sun, 13 Nov 2016 22:58:42 +0000 (23:58 +0100)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Mon, 14 Nov 2016 00:19:26 +0000 (01:19 +0100)
src/com/hughes/android/dictionary/DictionaryActivity.java

index 6dc95c68dc95b2c9bdba2d18f4c9d418201718a9..6366812fc9c22368a875d05f94b829aa6a8c7761 100644 (file)
@@ -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;
         }