Merge "Scroll to bottom of screen when adding preferences via code" into oc-dev
diff --git a/tests/tests/preference2/src/android/preference2/cts/PreferenceRecycleTest.java b/tests/tests/preference2/src/android/preference2/cts/PreferenceRecycleTest.java
index 9d0242d..598780ce 100644
--- a/tests/tests/preference2/src/android/preference2/cts/PreferenceRecycleTest.java
+++ b/tests/tests/preference2/src/android/preference2/cts/PreferenceRecycleTest.java
@@ -127,6 +127,12 @@
             screen.addPreference(noRecyclePref);
         });
 
+        // Select the last item in the list to make sure the newly added prefs is actually
+        // displayed even on small screen like watches.
+        mActivityRule.runOnUiThread(() -> {
+            mActivity.getListView().setSelection(mActivity.getListView().getCount() - 1);
+        });
+
         // Grab the preferences we just created on the Ui thread.
         RecycleCheckPreference recyclePref =
                 (RecycleCheckPreference)screen.findPreference("recyclePref");