diff --git a/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java b/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java index 315ebf6..d745df7 100644 --- a/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java +++ b/pulltorefresh/src/com/markupartist/android/widget/PullToRefreshListView.java @@ -2,6 +2,9 @@ import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; @@ -54,6 +57,8 @@ public class PullToRefreshListView extends ListView implements OnScrollListener private int mRefreshOriginalTopPadding; private int mLastMotionY; + private Drawable mArrowDrawable = null; + private boolean mBounceHack; public PullToRefreshListView(Context context) { @@ -101,6 +106,8 @@ private void init(Context context) { (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_updated_at); mRefreshViewImage.setMinimumHeight(50); + mArrowDrawable = mRefreshViewImage.getDrawable(); + mRefreshView.setOnClickListener(new OnClickRefreshListener()); mRefreshOriginalTopPadding = mRefreshView.getPaddingTop(); @@ -244,7 +251,7 @@ private void resetHeader() { // Set refresh view text to the pull label mRefreshViewText.setText(R.string.pull_to_refresh_tap_label); // Replace refresh drawable with arrow drawable - mRefreshViewImage.setImageResource(R.drawable.ic_pulltorefresh_arrow); + mRefreshViewImage.setImageDrawable(mArrowDrawable); // Clear the full rotation animation mRefreshViewImage.clearAnimation(); // Hide progress bar and arrow. @@ -330,6 +337,19 @@ public void onScrollStateChanged(AbsListView view, int scrollState) { } } + public void setArrowResource(int resId) { + setArrowDrawable(getResources().getDrawable(resId)); + } + + public void setArrowBitmap(Bitmap arrow) { + setArrowDrawable(new BitmapDrawable(arrow)); + } + + public void setArrowDrawable(Drawable arrow) { + mArrowDrawable = arrow; + mRefreshViewImage.setImageDrawable(arrow); + } + public void prepareForRefresh() { resetHeaderPadding();