summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-02-19 14:15:57 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-02-19 14:15:57 -0800
commitea0ce99d296516ee737adb1b5c42948bb322850f (patch)
tree13f8ffe2222289e8317b30a994e255773997b017 /core
parent32637cf9fd71096becb4f43bde56e9137b8187e4 (diff)
parent1f09c8314701c1d09be8e350344c58241905677b (diff)
downloadframeworks_base-ea0ce99d296516ee737adb1b5c42948bb322850f.zip
frameworks_base-ea0ce99d296516ee737adb1b5c42948bb322850f.tar.gz
frameworks_base-ea0ce99d296516ee737adb1b5c42948bb322850f.tar.bz2
Merge "Spinner now allows disabled adapter items"
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/Spinner.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java
index bcddca1..2f6dd1e 100644
--- a/core/java/android/widget/Spinner.java
+++ b/core/java/android/widget/Spinner.java
@@ -295,14 +295,18 @@ public class Spinner extends AbsSpinner implements OnClickListener {
*/
private static class DropDownAdapter implements ListAdapter, SpinnerAdapter {
private SpinnerAdapter mAdapter;
+ private ListAdapter mListAdapter;
/**
- * <p>Creates a new ListAddapter wrapper for the specified adapter.</p>
+ * <p>Creates a new ListAdapter wrapper for the specified adapter.</p>
*
* @param adapter the Adapter to transform into a ListAdapter
*/
public DropDownAdapter(SpinnerAdapter adapter) {
this.mAdapter = adapter;
+ if (adapter instanceof ListAdapter) {
+ this.mListAdapter = (ListAdapter) adapter;
+ }
}
public int getCount() {
@@ -343,21 +347,29 @@ public class Spinner extends AbsSpinner implements OnClickListener {
}
/**
- * <p>Always returns false.</p>
- *
- * @return false
+ * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
+ * Otherwise, return true.
*/
public boolean areAllItemsEnabled() {
- return true;
+ final ListAdapter adapter = mListAdapter;
+ if (adapter != null) {
+ return adapter.areAllItemsEnabled();
+ } else {
+ return true;
+ }
}
/**
- * <p>Always returns false.</p>
- *
- * @return false
+ * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call.
+ * Otherwise, return true.
*/
public boolean isEnabled(int position) {
- return true;
+ final ListAdapter adapter = mListAdapter;
+ if (adapter != null) {
+ return adapter.isEnabled(position);
+ } else {
+ return true;
+ }
}
public int getItemViewType(int position) {