diff --git a/api/current.xml b/api/current.xml
index ebb8b3e19f6f8..aa75729ad557a 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -228878,6 +228878,21 @@
+
+
+
+
+
+
extends ViewGroup {
super(context, attrs, defStyle);
}
-
/**
* Interface definition for a callback to be invoked when an item in this
* AdapterView has been clicked.
@@ -629,6 +628,7 @@ public abstract class AdapterView extends ViewGroup {
/**
* Sets the view to show if the adapter is empty
*/
+ @android.view.RemotableViewMethod
public void setEmptyView(View emptyView) {
mEmptyView = emptyView;
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java
index e78c8b747f09e..0636d721c1487 100644
--- a/core/java/android/widget/AdapterViewAnimator.java
+++ b/core/java/android/widget/AdapterViewAnimator.java
@@ -688,6 +688,7 @@ public abstract class AdapterViewAnimator extends AdapterView
}
mAdapter = adapter;
+ checkFocus();
if (mAdapter != null) {
mDataSetObserver = new AdapterDataSetObserver();
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index f23a7239ede96..0ca71e1665c9f 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -17,6 +17,7 @@
package android.widget;
import android.app.PendingIntent;
+import android.appwidget.AppWidgetHostView;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
@@ -110,6 +111,42 @@ public class RemoteViews implements Parcelable, Filter {
}
}
+ private class SetEmptyView extends Action {
+ int viewId;
+ int emptyViewId;
+
+ public final static int TAG = 6;
+
+ SetEmptyView(int viewId, int emptyViewId) {
+ this.viewId = viewId;
+ this.emptyViewId = emptyViewId;
+ }
+
+ SetEmptyView(Parcel in) {
+ this.viewId = in.readInt();
+ this.emptyViewId = in.readInt();
+ }
+
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(TAG);
+ out.writeInt(this.viewId);
+ out.writeInt(this.emptyViewId);
+ }
+
+ @Override
+ public void apply(View root) {
+ final View view = root.findViewById(viewId);
+ if (!(view instanceof AdapterView>)) return;
+
+ AdapterView> adapterView = (AdapterView>) view;
+
+ final View emptyView = root.findViewById(emptyViewId);
+ if (emptyView == null) return;
+
+ adapterView.setEmptyView(emptyView);
+ }
+ }
+
/**
* Equivalent to calling
* {@link android.view.View#setOnClickListener(android.view.View.OnClickListener)}
@@ -631,6 +668,9 @@ public class RemoteViews implements Parcelable, Filter {
case ReflectionActionWithoutParams.TAG:
mActions.add(new ReflectionActionWithoutParams(parcel));
break;
+ case SetEmptyView.TAG:
+ mActions.add(new SetEmptyView(parcel));
+ break;
default:
throw new ActionException("Tag " + tag + " not found");
}
@@ -759,6 +799,16 @@ public class RemoteViews implements Parcelable, Filter {
setBitmap(viewId, "setImageBitmap", bitmap);
}
+ /**
+ * Equivalent to calling AdapterView.setEmptyView
+ *
+ * @param viewId The id of the view on which to set the empty view
+ * @param emptyViewId The view id of the empty view
+ */
+ public void setEmptyView(int viewId, int emptyViewId) {
+ addAction(new SetEmptyView(viewId, emptyViewId));
+ }
+
/**
* Equivalent to calling {@link Chronometer#setBase Chronometer.setBase},
* {@link Chronometer#setFormat Chronometer.setFormat},
diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java
index b460adb8d47bc..9816b395a2a1b 100644
--- a/core/java/android/widget/StackView.java
+++ b/core/java/android/widget/StackView.java
@@ -124,6 +124,9 @@ public class StackView extends AdapterViewAnimator {
}
setClipChildren(false);
setClipToPadding(false);
+
+ // This is a flag to indicate the the stack is loading for the first time
+ mWhichChild = -1;
}
/**
@@ -638,6 +641,10 @@ public class StackView extends AdapterViewAnimator {
@Override
public void onRemoteAdapterConnected() {
super.onRemoteAdapterConnected();
+ // On first run, we want to set the stack to the end.
+ if (mAdapter != null && mWhichChild == -1) {
+ mWhichChild = mAdapter.getCount() - 1;
+ }
setDisplayedChild(mWhichChild);
}