- 浏览: 36317 次
- 性别:
- 来自: 北京
最新评论
-
kkmike999:
这个是我自己的Demo,希望给大家参考一下http://dow ...
android 图片转 圆形和圆角矩形 -
qiliannujian:
相当不错但是我需要把他放到中间 扇形开花怎么办呢
android path 动画效果 (很酷) -
yunduan:
太给力了,求源码一份,请多指教 535266711@qq.co ...
高仿新浪微博下拉刷新 -
zsq2009:
同求一份源码,379858217@qq.com
高仿新浪微博下拉刷新 -
vary25:
效果非常棒 ,感谢分享
android path 动画效果 (很酷)
自己写了个模仿新浪下拉刷新的效果。通过菜单选择 自动加载更多 或 手动加载更多。绝非修改国外那哥们写的。
改进版 下拉刷新 代码:
效果请访问 www.lianluoquan.com
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Scroller;
import android.widget.TextView;
import android.widget.Toast;
public class SimplePullDownView extends FrameLayout implements
GestureDetector.OnGestureListener, Animation.AnimationListener {
String tag = "SimplePullDownView";
private class CheckForLongPress implements Runnable {
public void run() {
// Log.e(tag, "长按检查方法执行");
if(mListView.getOnItemLongClickListener() == null){
/*MotionEvent e = MotionEvent.obtain(downEvent.getDownTime(), downEvent.getEventTime() + ViewConfiguration.getLongPressTimeout() + 100, MotionEvent.ACTION_CANCEL, downEvent.getX(), downEvent.getY(), downEvent.getMetaState());
SimplePullDownView.super.dispatchTouchEvent(e);*/
}
else {
postDelayed(mPendingCheckForLongPress2, 100);
}
}
}
private class CheckForLongPress2 implements Runnable {
public void run() {
// Log.e(tag, "长按检查方法执行2 ----> 延后 100 " );
mLongPressing = true;
MotionEvent e = MotionEvent.obtain(downEvent.getDownTime(), downEvent.getEventTime() + ViewConfiguration.getLongPressTimeout(), MotionEvent.ACTION_CANCEL, downEvent.getX(), downEvent.getY(), downEvent.getMetaState());
SimplePullDownView.super.dispatchTouchEvent(e);
}
}
class FlingRunnable implements Runnable {
private void startCommon() {
removeCallbacks(this);
}
public void run() {
boolean noFinish = mScroller.computeScrollOffset();
int curY = mScroller.getCurrY();
int deltaY = curY - mLastFlingY;
// Log.e("SimplePullDownView", "deltaY = " + deltaY + " , noFinish = " + noFinish);
// updateView();
if (noFinish/* && deltaY!=0*/) {
move(deltaY, true);
mLastFlingY = curY;
post(this);
} else {
removeCallbacks(this);
if(mState == SCROLL_TO_CLOSE){
mState = -1;
}
}
}
public void startUsingDistance(int distance, int duration) {
if (distance == 0)
distance--;
startCommon();
mLastFlingY = 0;
mScroller.startScroll(0, 0, 0, distance, duration);
post(this);
}
private int mLastFlingY;
private Scroller mScroller;
public FlingRunnable() {
mScroller = new Scroller(getContext());
}
}
public interface OnRefreshListioner {
public abstract void onRefresh();
public abstract void onLoadMore();
}
public SimplePullDownView(Context context) {
super(context);
mDetector = new GestureDetector(context, this);
mFlinger = new FlingRunnable();
init();
addRefreshBar();
}
public SimplePullDownView(Context context, AttributeSet att) {
super(context, att);
useempty = att.getAttributeBooleanValue(null, "useempty", true);
//Log.e(tag, "useempty = " + useempty);
mDetector = new GestureDetector(this);
mFlinger = new FlingRunnable();
init();
addRefreshBar();
}
private void addRefreshBar() {
mAnimationUp = AnimationUtils.loadAnimation(getContext(), R.anim.rotate_up);
mAnimationUp.setAnimationListener(this);
mAnimationDown = AnimationUtils.loadAnimation(getContext(),R.anim.rotate_down);
mAnimationDown.setAnimationListener(this);
View view = LayoutInflater.from(getContext()).inflate(R.layout.refresh_bar, null);
// view.setVisibility(View.INVISIBLE);
view.setBackgroundColor(0xfff4f4f4);
addView(view);
mFirstChild = (LinearLayout) view;
mUpdateContent = (FrameLayout) getChildAt(0).findViewById(R.id.iv_content);
mArrow = new ImageView(getContext());
mArrow.setBackgroundColor(0xfff4f4f4);
FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
mArrow.setScaleType(ImageView.ScaleType.FIT_CENTER);
mArrow.setLayoutParams(layoutparams);
mArrow.setImageResource( R.drawable.arrow_down);
mUpdateContent.addView(mArrow);
FrameLayout.LayoutParams layoutparams1 = new FrameLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
layoutparams1.gravity = Gravity.CENTER;
// int defstyle = android.R.style.Widget_ProgressBar_Small_Inverse;
mProgressBar = new ProgressBar(getContext(), null, android.R.attr.progressBarStyleSmallInverse);
mProgressBar.setIndeterminate(false);
mProgressBar.setBackgroundColor(0xfff4f4f4);
// mProgressBar.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progress_small));
int i = getResources().getDimensionPixelSize(R.dimen.updatebar_padding);
mProgressBar.setPadding(i, i, i, i);
mProgressBar.setLayoutParams(layoutparams1);
mUpdateContent.addView(mProgressBar);
mTitle = (TextView) findViewById(R.id.ref_title);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mListView = (ListView) getChildAt(1);
footer_layout = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.empty_main, null);
foot = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.ref2, null);
// footer_layout.addView(foot);
more = (TextView) foot.findViewById(R.id.ref);
mProgressBar2 = (ProgressBar) foot.findViewById(R.id.refbar);
// mProgressBar2.setVisibility(View.INVISIBLE);
if(useempty){
header = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.empty_main, null);
mListView.addHeaderView(header);
}
mListView.addFooterView(footer_layout);
foot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!isAutoLoadMore)
onLoadMore();
}
});
mListView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// Log.i("SimplePullDownView", "scrollState = " + scrollState);
if(isEnd && scrollState == SCROLL_STATE_IDLE && hasMore && isAutoLoadMore){
onLoadMore();
}
}
@Override
public void onScroll(AbsListView view, int f, int v, int t) {
// Log.i("SimplePullDownView", "first = " + f + " , visable = " + v + " , total = " + t + " , hasMore = " + hasMore);
if(isAutoLoadMore){
if(f + v >= t - 1)
isEnd = true;
else
isEnd = false;
}
}
});
}
/**
* 设置没有数据时默认图片
* @param empty
*/
public void setEmptyHeaderView(View empty){
emptyHeaderView = empty;
}
public void addEmptyHeaderView(){
header.removeAllViews();
if(emptyHeaderView != null)
header.addView(emptyHeaderView);
}
public void removeEmptyHeaderView(){
if(emptyHeaderView != null)
header.removeView(emptyHeaderView);
}
private void init() {
MAX_LENGHT = getResources().getDimensionPixelSize(R.dimen.updatebar_height );//62.0dip
setDrawingCacheEnabled(false);
setBackgroundDrawable(null);
setClipChildren(false);
mDetector.setIsLongpressEnabled(false);
mPading = -MAX_LENGHT;
// mLastPading = -MAX_LENGHT;
mLastTop = -MAX_LENGHT;
pulldowntorefresh = getContext().getText(R.string.drop_dowm).toString();
releasetorefresh = getContext().getText(R.string.release_update).toString();
loading = getContext().getText(R.string.doing_update).toString();
update_time = getContext().getText(R.string.update_time).toString();
}
/** deltaY > 0 向上 */
private boolean move(float deltaY, boolean auto) {
// //Log.e("SimplePullDownView","move 方法执行 " );
if(deltaY > 0 && mFirstChild.getTop() == -MAX_LENGHT){
mPading = -MAX_LENGHT;
return false;
}
if(auto){
// Log.i("SimplePullDownView","move 方法执行 mPading = " + mPading);
if(mFirstChild.getTop()-deltaY < mDestPading){
deltaY = mFirstChild.getTop() - mDestPading;
}
mFirstChild.offsetTopAndBottom((int) -deltaY);
mListView.offsetTopAndBottom((int) -deltaY);
mPading = mFirstChild.getTop();
if(mDestPading == 0 && mFirstChild.getTop() == 0 && mState ==SCROLL_TO_REFRESH ){
//Log.e("SimplePullDownView","onRefresh 刷新方法执行 --->");
onRefresh();
} else if(mDestPading == -MAX_LENGHT){
}
invalidate();
updateView();
return true;
} else {
if(mState != STATE_REFRESH || (mState == STATE_REFRESH && deltaY>0)){
mFirstChild.offsetTopAndBottom((int) -deltaY);
mListView.offsetTopAndBottom((int) -deltaY);
mPading = mFirstChild.getTop();
} else if(mState == STATE_REFRESH && deltaY<0 && mFirstChild.getTop()<=0){
if(mFirstChild.getTop() - deltaY > 0){
deltaY = mFirstChild.getTop();
}
mFirstChild.offsetTopAndBottom((int) -deltaY);
mListView.offsetTopAndBottom((int) -deltaY);
mPading = mFirstChild.getTop();
}
}
if(deltaY > 0 && mFirstChild.getTop() <= -MAX_LENGHT){
mPading = -MAX_LENGHT;
deltaY = -MAX_LENGHT - mFirstChild.getTop();
mFirstChild.offsetTopAndBottom((int) deltaY);
mListView.offsetTopAndBottom((int) deltaY);
mPading = mFirstChild.getTop();
updateView();
invalidate();
return false;
}
updateView();
invalidate();
return true;
}
private void updateView() {
String s = "";
s = mDate == null? "" : update_time + mDate ;
if(mState != STATE_REFRESH){
if(mFirstChild.getTop() < 0){
mArrow.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.INVISIBLE);
mTitle.setText(pulldowntorefresh + s);
if(mLastTop >= 0 && mState != SCROLL_TO_CLOSE){
mArrow.startAnimation(mAnimationUp);
//Log.i("SimplePullDownView", " mAnimationUp 上动画 " );
}
} else if(mFirstChild.getTop() > 0){
mTitle.setText(releasetorefresh + s);
mProgressBar.setVisibility(View.INVISIBLE);
mArrow.setVisibility(View.VISIBLE);
if(mLastTop <= 0 ){
mArrow.startAnimation(mAnimationDown);
//Log.i("SimplePullDownView", " mAnimationDown 下动画 " );
}
}
}
mLastTop = mFirstChild.getTop();
}
private boolean release()
{
//Log.i("SimplePullDownView", "release 方法执行 = " + " , mFirstChild.getTop() = " + mFirstChild.getTop());
if(listviewDoScroll){
listviewDoScroll = false;
return true;
}
if(mFirstChild.getTop()>0){
scrollToUpdate();
} else {
scrollToClose();
// mDestPading = -MAX_LENGHT;
}
invalidate();
return false;
}
private void scrollToClose() {
mDestPading = -MAX_LENGHT;
mFlinger.startUsingDistance(MAX_LENGHT, CLOSEDELAY);
}
private void scrollToUpdate() {
mState = SCROLL_TO_REFRESH;
//Log.e("SimplePullDownView", "scrollToUpdate 方法执行");
mDestPading = 0;
mFlinger.startUsingDistance(mFirstChild.getTop(), REFRESHDELAY);
}
private void onRefresh(){
mState = STATE_REFRESH;
String s = "";
if(mDate == null)
s = "";
else
s = update_time + mDate;
mTitle.setText(loading + s);
mProgressBar.setVisibility(View.VISIBLE);
mArrow.setVisibility(View.INVISIBLE);
if(mRefreshListioner != null){
mRefreshListioner.onRefresh();
}
}
public void onRefreshComplete(){
onRefreshComplete(null);
}
public void onRefreshComplete(String date){
//Log.e("SimplePullDownView", "onRefreshComplete 方法执行 ");
mDate = date;
mState = SCROLL_TO_CLOSE;
/* mPading = -MAX_LENGHT;
mLastPading = -MAX_LENGHT;*/
mArrow.setImageResource(R.drawable.arrow_down);
mProgressBar2.setVisibility(View.INVISIBLE);
updateCommon();
scrollToClose();
}
private void updateCommon(){
if(mListView.getCount() == (mListView.getHeaderViewsCount() + mListView.getFooterViewsCount())){
Log.e("out", "数据为空");
if(useempty)
addEmptyHeaderView();
footer_layout.removeAllViews();
mListView.setFooterDividersEnabled(false);
} else {
removeEmptyHeaderView();
if(hasMore){
mListView.setFooterDividersEnabled(true);
footer_layout.removeAllViews();
footer_layout.addView(foot);
}else {
mListView.setFooterDividersEnabled(false);
footer_layout.removeAllViews();
}
}
}
public void onFirstLoad(){
if(footer_layout.getChildCount() == 0){
footer_layout.addView(foot);
}
isFirstLoading = true;
foot.setEnabled(false);
//Log.e("SimplePullDownView", "onFirstLoad 方法执行 ");
mState = STATE_REFRESH;
mProgressBar2.setVisibility(View.VISIBLE);
more.setText(R.string.loading2);
}
public void onLoadMore(){
//Log.e("SimplePullDownView", "onLoadMore 方法执行 ");
foot.setEnabled(false);
mState = STATE_REFRESH;
mProgressBar2.setVisibility(View.VISIBLE);
more.setText(R.string.loading2);
if(mRefreshListioner != null){
mRefreshListioner.onLoadMore();
}
}
public void onLoadMoreComplete(String date){
//Log.e("SimplePullDownView", "onLoadMoreComplete 方法执行 ");
mDate = date;
mState = -1;
mProgressBar2.setVisibility(View.INVISIBLE);
more.setText(R.string.more);
updateCommon();
if(isFirstLoading)
isFirstLoading = false;
foot.setEnabled(true);
}
public void onLoadMoreComplete( ){
onLoadMoreComplete(null);
}
public boolean dispatchTouchEvent(MotionEvent e){
//Log.e("SimplePullDownView", "dispatchTouchEvent ----------> ");
if(isFirstLoading){
return false;
}
int action;
float y = e.getY();
action = e.getAction();
if(mLongPressing && action != MotionEvent.ACTION_DOWN){
return false;
}
if(e.getAction() == MotionEvent.ACTION_DOWN){
mLongPressing = true;
}
boolean handled = true;
handled = mDetector.onTouchEvent(e);
// if(!handled)
// Log.i("SimplePullDownView", " mDetector.onTouchEvent handled = " + handled + " , mPading = " + mPading);
switch (action) {
case MotionEvent.ACTION_UP:
/*mListView.getHitRect(r);
boolean f = r.contains((int)e.getX(), (int)e.getY());*/
boolean f1 = mListView.getTop() <= e.getY() && e.getY() <= mListView.getBottom();
// Log.e("SimplePullDownView", " ACTION_UP -------> handled = " + handled + " , f1 = " + f1 + " , top == -MAX = " +(mFirstChild.getTop() == -MAX_LENGHT) );
if(!handled && mFirstChild.getTop() == -MAX_LENGHT && f1 || mState == STATE_REFRESH){
super.dispatchTouchEvent(e);
}
else{
// Log.e("SimplePullDownView", "执行释放方法 listviewDoScroll = " + listviewDoScroll);
handled = release();
}
break;
case MotionEvent.ACTION_CANCEL:
// Log.e(tag, " event: ACTION_CANCEL" );
handled = release();
super.dispatchTouchEvent(e);
break;
case MotionEvent.ACTION_DOWN:
downEvent = e;
mLongPressing = false;
// Log.e(tag, " 长按的时间间隔:" + ViewConfiguration.getLongPressTimeout());
postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout()+ 100);
mPendingRemoved = false;
downPostion = mListView.pointToPosition((int)e.getX(), (int)e.getY()) - mListView.getHeaderViewsCount();
//Log.e("SimplePullDownView", "downPostion = " + downPostion);
super.dispatchTouchEvent(e);
break;
case MotionEvent.ACTION_MOVE:
float deltaY = lastY - y;
lastY = y;
if(!mPendingRemoved){
removeCallbacks(mPendingCheckForLongPress);
mPendingRemoved = true;
}
//Log.e("SimplePullDownView","handled = " + handled + " , top = " + mFirstChild.getTop());
if(!handled && mFirstChild.getTop() == -MAX_LENGHT){
try{
return super.dispatchTouchEvent(e);
} catch (Exception e2) {
e2.printStackTrace();
return true;
}
}
else if(handled && mListView.getTop() > 0 && deltaY < 0){//deltaY小于0,向下
e.setAction(MotionEvent.ACTION_CANCEL);
super.dispatchTouchEvent(e);
}
break;
default:
break;
}
return true;
}
public void onAnimationEnd(Animation animation) {
int top = mFirstChild.getTop();
if (top < 0)
mArrow.setImageResource(R.drawable.arrow_down);
else if (top > 0)
mArrow.setImageResource(R.drawable.arrow_up);
else {
if(top < mLastTop){
mArrow.setImageResource(R.drawable.arrow_down);
} else {
mArrow.setImageResource(R.drawable.arrow_up);
}
}
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
public boolean onDown(MotionEvent e) {
return false;
}
public boolean onFling(MotionEvent motionevent, MotionEvent e,
float f, float f1) {
return false;
}
protected void onLayout(boolean flag, int i, int j, int k, int l) {
// Log.i("SimplePullDownView", "onLayout 方法执行 ------> mPading = " + mPading + " , listTop = " + (mPading + MAX_LENGHT));
int top = mPading;
int w = getMeasuredWidth();
mFirstChild.layout(0, top, w, top + MAX_LENGHT);
int h = getMeasuredHeight() + mPading + MAX_LENGHT;
mListView.layout(0, top + MAX_LENGHT , w, h);
}
public void onLongPress(MotionEvent e) {
}
/** deltaY > 0 向上*/
public boolean onScroll(MotionEvent curdown, MotionEvent cur, float deltaX, float deltaY) {
// mListView.getHitRect(r);
// Log.i("SimplePullDownView", "父亲高度 : = " + getHeight() + " , width = " + r.width() + " , height = " + r.height() + " , top = " + r.top + " , bottom = " + r.bottom);
deltaY = (float) ((double) deltaY * SCALE);
boolean handled = false;
boolean flag = false;
if (mListView.getCount() == 0) {
flag = true;
} else {
View c = mListView.getChildAt(0);
if (mListView.getFirstVisiblePosition() == 0 && c!=null && c.getTop() == 0){
flag = true;
}
// Log.i("SimplePullDownView","onScroll 方法执行 mPading = " + mPading + ", mTop = " + adapterview.getTop() + " flag = " + flag + " , deltaY = " + deltaY);
}
if (deltaY < 0F && flag || getChildAt(0).getTop() > -MAX_LENGHT){ //deltaY < 0 向下
handled = move(deltaY, false);
// Log.i("SimplePullDownView", "满足条件 执行 move 方法, handled = " + handled);
}
else
handled = false;
// Log.i("SimplePullDownView", " onScroll handled = " + handled);
return handled;
}
public void onShowPress(MotionEvent motionevent) {
}
public boolean onSingleTapUp(MotionEvent motionevent) {
return false;
}
public void setRefreshListioner(OnRefreshListioner RefreshListioner) {
mRefreshListioner = RefreshListioner;
}
public boolean isAutoLoadMore() {
return isAutoLoadMore;
}
public void setAutoLoadMore(boolean isAutoLoadMore) {
this.isAutoLoadMore = isAutoLoadMore;
if(!isAutoLoadMore){
foot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onLoadMore();
}
});
mListView.setOnScrollListener(null);
} else {
mListView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// Log.i("SimplePullDownView", "scrollState = " + scrollState);
if(isEnd && scrollState == SCROLL_STATE_IDLE && hasMore){
onLoadMore();
}
}
@Override
public void onScroll(AbsListView view, int f, int v, int t) {
// Log.i("SimplePullDownView", "first = " + f + " , visable = " + v + " , total = " + t + " , hasMore = " + hasMore);
if(f + v >= t - 1)
isEnd = true;
else
isEnd = false;
}
});
foot.setOnClickListener(null);
}
}
public void setHasMore(boolean hasMore) {
this.hasMore = hasMore;
}
public void removeFoot(){
footer_layout.removeAllViews();
}
public void addFoot(){
footer_layout.removeAllViews();
footer_layout.addView(foot);
}
public static int MAX_LENGHT = 0;
public static final int STATE_REFRESH = 1;
public static final int SCROLL_TO_CLOSE = 2;
public static final int SCROLL_TO_REFRESH = 3;
public static final double SCALE = 0.9d;
private static final int CLOSEDELAY = 300;
private static final int REFRESHDELAY = 300;
private Animation mAnimationDown;
private Animation mAnimationUp;
private ImageView mArrow;
private String mDate;
private View emptyHeaderView;
private ProgressBar mProgressBar;
private TextView more;
private ProgressBar mProgressBar2;
private int mState;
private TextView mTitle;
ListView mListView;
LinearLayout foot;
LinearLayout footer_layout;
LinearLayout header;
private GestureDetector mDetector;
private FlingRunnable mFlinger;
private int mPading;
private int mDestPading;
// private int mLastPading;
private int mLastTop;
private LinearLayout mFirstChild;
private FrameLayout mUpdateContent;
private OnRefreshListioner mRefreshListioner;
private boolean isAutoLoadMore = false;
private boolean hasMore = true;
private boolean isEnd = true;
private boolean listviewDoScroll = false;
private boolean isFirstLoading = false;
// private boolean mIsAutoScroller;
private boolean mLongPressing;//如果设置为true说明刚好到了执行长按的时间
private boolean mPendingRemoved = false;//
private String pulldowntorefresh;
private String releasetorefresh;
private String loading;
private String update_time;
Rect r = new Rect();
private int downPostion;
private MotionEvent downEvent;
private CheckForLongPress mPendingCheckForLongPress = new CheckForLongPress();
private CheckForLongPress2 mPendingCheckForLongPress2 = new CheckForLongPress2();
private float lastY;
private boolean useempty = true;
}
Offset this view's vertical location by the specified number of pixels.
我贴的源码是最新的,但那个例子里的代码不是最新的,我这没有最新的例子
能不能把你的代码发我一份呢, 谢谢您了的啊。 麻烦了的 79144876@qq.com
我贴的源码是最新的,但那个例子里的代码不是最新的,我这没有最新的例子
这个你可以自己加啊
晕。你的代码也写得太高深了。看不太懂。嘿嘿
这个你可以自己加啊
改进版 下拉刷新 代码:
效果请访问 www.lianluoquan.com
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.Scroller;
import android.widget.TextView;
import android.widget.Toast;
public class SimplePullDownView extends FrameLayout implements
GestureDetector.OnGestureListener, Animation.AnimationListener {
String tag = "SimplePullDownView";
private class CheckForLongPress implements Runnable {
public void run() {
// Log.e(tag, "长按检查方法执行");
if(mListView.getOnItemLongClickListener() == null){
/*MotionEvent e = MotionEvent.obtain(downEvent.getDownTime(), downEvent.getEventTime() + ViewConfiguration.getLongPressTimeout() + 100, MotionEvent.ACTION_CANCEL, downEvent.getX(), downEvent.getY(), downEvent.getMetaState());
SimplePullDownView.super.dispatchTouchEvent(e);*/
}
else {
postDelayed(mPendingCheckForLongPress2, 100);
}
}
}
private class CheckForLongPress2 implements Runnable {
public void run() {
// Log.e(tag, "长按检查方法执行2 ----> 延后 100 " );
mLongPressing = true;
MotionEvent e = MotionEvent.obtain(downEvent.getDownTime(), downEvent.getEventTime() + ViewConfiguration.getLongPressTimeout(), MotionEvent.ACTION_CANCEL, downEvent.getX(), downEvent.getY(), downEvent.getMetaState());
SimplePullDownView.super.dispatchTouchEvent(e);
}
}
class FlingRunnable implements Runnable {
private void startCommon() {
removeCallbacks(this);
}
public void run() {
boolean noFinish = mScroller.computeScrollOffset();
int curY = mScroller.getCurrY();
int deltaY = curY - mLastFlingY;
// Log.e("SimplePullDownView", "deltaY = " + deltaY + " , noFinish = " + noFinish);
// updateView();
if (noFinish/* && deltaY!=0*/) {
move(deltaY, true);
mLastFlingY = curY;
post(this);
} else {
removeCallbacks(this);
if(mState == SCROLL_TO_CLOSE){
mState = -1;
}
}
}
public void startUsingDistance(int distance, int duration) {
if (distance == 0)
distance--;
startCommon();
mLastFlingY = 0;
mScroller.startScroll(0, 0, 0, distance, duration);
post(this);
}
private int mLastFlingY;
private Scroller mScroller;
public FlingRunnable() {
mScroller = new Scroller(getContext());
}
}
public interface OnRefreshListioner {
public abstract void onRefresh();
public abstract void onLoadMore();
}
public SimplePullDownView(Context context) {
super(context);
mDetector = new GestureDetector(context, this);
mFlinger = new FlingRunnable();
init();
addRefreshBar();
}
public SimplePullDownView(Context context, AttributeSet att) {
super(context, att);
useempty = att.getAttributeBooleanValue(null, "useempty", true);
//Log.e(tag, "useempty = " + useempty);
mDetector = new GestureDetector(this);
mFlinger = new FlingRunnable();
init();
addRefreshBar();
}
private void addRefreshBar() {
mAnimationUp = AnimationUtils.loadAnimation(getContext(), R.anim.rotate_up);
mAnimationUp.setAnimationListener(this);
mAnimationDown = AnimationUtils.loadAnimation(getContext(),R.anim.rotate_down);
mAnimationDown.setAnimationListener(this);
View view = LayoutInflater.from(getContext()).inflate(R.layout.refresh_bar, null);
// view.setVisibility(View.INVISIBLE);
view.setBackgroundColor(0xfff4f4f4);
addView(view);
mFirstChild = (LinearLayout) view;
mUpdateContent = (FrameLayout) getChildAt(0).findViewById(R.id.iv_content);
mArrow = new ImageView(getContext());
mArrow.setBackgroundColor(0xfff4f4f4);
FrameLayout.LayoutParams layoutparams = new FrameLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
mArrow.setScaleType(ImageView.ScaleType.FIT_CENTER);
mArrow.setLayoutParams(layoutparams);
mArrow.setImageResource( R.drawable.arrow_down);
mUpdateContent.addView(mArrow);
FrameLayout.LayoutParams layoutparams1 = new FrameLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
layoutparams1.gravity = Gravity.CENTER;
// int defstyle = android.R.style.Widget_ProgressBar_Small_Inverse;
mProgressBar = new ProgressBar(getContext(), null, android.R.attr.progressBarStyleSmallInverse);
mProgressBar.setIndeterminate(false);
mProgressBar.setBackgroundColor(0xfff4f4f4);
// mProgressBar.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progress_small));
int i = getResources().getDimensionPixelSize(R.dimen.updatebar_padding);
mProgressBar.setPadding(i, i, i, i);
mProgressBar.setLayoutParams(layoutparams1);
mUpdateContent.addView(mProgressBar);
mTitle = (TextView) findViewById(R.id.ref_title);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mListView = (ListView) getChildAt(1);
footer_layout = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.empty_main, null);
foot = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.ref2, null);
// footer_layout.addView(foot);
more = (TextView) foot.findViewById(R.id.ref);
mProgressBar2 = (ProgressBar) foot.findViewById(R.id.refbar);
// mProgressBar2.setVisibility(View.INVISIBLE);
if(useempty){
header = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.empty_main, null);
mListView.addHeaderView(header);
}
mListView.addFooterView(footer_layout);
foot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!isAutoLoadMore)
onLoadMore();
}
});
mListView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// Log.i("SimplePullDownView", "scrollState = " + scrollState);
if(isEnd && scrollState == SCROLL_STATE_IDLE && hasMore && isAutoLoadMore){
onLoadMore();
}
}
@Override
public void onScroll(AbsListView view, int f, int v, int t) {
// Log.i("SimplePullDownView", "first = " + f + " , visable = " + v + " , total = " + t + " , hasMore = " + hasMore);
if(isAutoLoadMore){
if(f + v >= t - 1)
isEnd = true;
else
isEnd = false;
}
}
});
}
/**
* 设置没有数据时默认图片
* @param empty
*/
public void setEmptyHeaderView(View empty){
emptyHeaderView = empty;
}
public void addEmptyHeaderView(){
header.removeAllViews();
if(emptyHeaderView != null)
header.addView(emptyHeaderView);
}
public void removeEmptyHeaderView(){
if(emptyHeaderView != null)
header.removeView(emptyHeaderView);
}
private void init() {
MAX_LENGHT = getResources().getDimensionPixelSize(R.dimen.updatebar_height );//62.0dip
setDrawingCacheEnabled(false);
setBackgroundDrawable(null);
setClipChildren(false);
mDetector.setIsLongpressEnabled(false);
mPading = -MAX_LENGHT;
// mLastPading = -MAX_LENGHT;
mLastTop = -MAX_LENGHT;
pulldowntorefresh = getContext().getText(R.string.drop_dowm).toString();
releasetorefresh = getContext().getText(R.string.release_update).toString();
loading = getContext().getText(R.string.doing_update).toString();
update_time = getContext().getText(R.string.update_time).toString();
}
/** deltaY > 0 向上 */
private boolean move(float deltaY, boolean auto) {
// //Log.e("SimplePullDownView","move 方法执行 " );
if(deltaY > 0 && mFirstChild.getTop() == -MAX_LENGHT){
mPading = -MAX_LENGHT;
return false;
}
if(auto){
// Log.i("SimplePullDownView","move 方法执行 mPading = " + mPading);
if(mFirstChild.getTop()-deltaY < mDestPading){
deltaY = mFirstChild.getTop() - mDestPading;
}
mFirstChild.offsetTopAndBottom((int) -deltaY);
mListView.offsetTopAndBottom((int) -deltaY);
mPading = mFirstChild.getTop();
if(mDestPading == 0 && mFirstChild.getTop() == 0 && mState ==SCROLL_TO_REFRESH ){
//Log.e("SimplePullDownView","onRefresh 刷新方法执行 --->");
onRefresh();
} else if(mDestPading == -MAX_LENGHT){
}
invalidate();
updateView();
return true;
} else {
if(mState != STATE_REFRESH || (mState == STATE_REFRESH && deltaY>0)){
mFirstChild.offsetTopAndBottom((int) -deltaY);
mListView.offsetTopAndBottom((int) -deltaY);
mPading = mFirstChild.getTop();
} else if(mState == STATE_REFRESH && deltaY<0 && mFirstChild.getTop()<=0){
if(mFirstChild.getTop() - deltaY > 0){
deltaY = mFirstChild.getTop();
}
mFirstChild.offsetTopAndBottom((int) -deltaY);
mListView.offsetTopAndBottom((int) -deltaY);
mPading = mFirstChild.getTop();
}
}
if(deltaY > 0 && mFirstChild.getTop() <= -MAX_LENGHT){
mPading = -MAX_LENGHT;
deltaY = -MAX_LENGHT - mFirstChild.getTop();
mFirstChild.offsetTopAndBottom((int) deltaY);
mListView.offsetTopAndBottom((int) deltaY);
mPading = mFirstChild.getTop();
updateView();
invalidate();
return false;
}
updateView();
invalidate();
return true;
}
private void updateView() {
String s = "";
s = mDate == null? "" : update_time + mDate ;
if(mState != STATE_REFRESH){
if(mFirstChild.getTop() < 0){
mArrow.setVisibility(View.VISIBLE);
mProgressBar.setVisibility(View.INVISIBLE);
mTitle.setText(pulldowntorefresh + s);
if(mLastTop >= 0 && mState != SCROLL_TO_CLOSE){
mArrow.startAnimation(mAnimationUp);
//Log.i("SimplePullDownView", " mAnimationUp 上动画 " );
}
} else if(mFirstChild.getTop() > 0){
mTitle.setText(releasetorefresh + s);
mProgressBar.setVisibility(View.INVISIBLE);
mArrow.setVisibility(View.VISIBLE);
if(mLastTop <= 0 ){
mArrow.startAnimation(mAnimationDown);
//Log.i("SimplePullDownView", " mAnimationDown 下动画 " );
}
}
}
mLastTop = mFirstChild.getTop();
}
private boolean release()
{
//Log.i("SimplePullDownView", "release 方法执行 = " + " , mFirstChild.getTop() = " + mFirstChild.getTop());
if(listviewDoScroll){
listviewDoScroll = false;
return true;
}
if(mFirstChild.getTop()>0){
scrollToUpdate();
} else {
scrollToClose();
// mDestPading = -MAX_LENGHT;
}
invalidate();
return false;
}
private void scrollToClose() {
mDestPading = -MAX_LENGHT;
mFlinger.startUsingDistance(MAX_LENGHT, CLOSEDELAY);
}
private void scrollToUpdate() {
mState = SCROLL_TO_REFRESH;
//Log.e("SimplePullDownView", "scrollToUpdate 方法执行");
mDestPading = 0;
mFlinger.startUsingDistance(mFirstChild.getTop(), REFRESHDELAY);
}
private void onRefresh(){
mState = STATE_REFRESH;
String s = "";
if(mDate == null)
s = "";
else
s = update_time + mDate;
mTitle.setText(loading + s);
mProgressBar.setVisibility(View.VISIBLE);
mArrow.setVisibility(View.INVISIBLE);
if(mRefreshListioner != null){
mRefreshListioner.onRefresh();
}
}
public void onRefreshComplete(){
onRefreshComplete(null);
}
public void onRefreshComplete(String date){
//Log.e("SimplePullDownView", "onRefreshComplete 方法执行 ");
mDate = date;
mState = SCROLL_TO_CLOSE;
/* mPading = -MAX_LENGHT;
mLastPading = -MAX_LENGHT;*/
mArrow.setImageResource(R.drawable.arrow_down);
mProgressBar2.setVisibility(View.INVISIBLE);
updateCommon();
scrollToClose();
}
private void updateCommon(){
if(mListView.getCount() == (mListView.getHeaderViewsCount() + mListView.getFooterViewsCount())){
Log.e("out", "数据为空");
if(useempty)
addEmptyHeaderView();
footer_layout.removeAllViews();
mListView.setFooterDividersEnabled(false);
} else {
removeEmptyHeaderView();
if(hasMore){
mListView.setFooterDividersEnabled(true);
footer_layout.removeAllViews();
footer_layout.addView(foot);
}else {
mListView.setFooterDividersEnabled(false);
footer_layout.removeAllViews();
}
}
}
public void onFirstLoad(){
if(footer_layout.getChildCount() == 0){
footer_layout.addView(foot);
}
isFirstLoading = true;
foot.setEnabled(false);
//Log.e("SimplePullDownView", "onFirstLoad 方法执行 ");
mState = STATE_REFRESH;
mProgressBar2.setVisibility(View.VISIBLE);
more.setText(R.string.loading2);
}
public void onLoadMore(){
//Log.e("SimplePullDownView", "onLoadMore 方法执行 ");
foot.setEnabled(false);
mState = STATE_REFRESH;
mProgressBar2.setVisibility(View.VISIBLE);
more.setText(R.string.loading2);
if(mRefreshListioner != null){
mRefreshListioner.onLoadMore();
}
}
public void onLoadMoreComplete(String date){
//Log.e("SimplePullDownView", "onLoadMoreComplete 方法执行 ");
mDate = date;
mState = -1;
mProgressBar2.setVisibility(View.INVISIBLE);
more.setText(R.string.more);
updateCommon();
if(isFirstLoading)
isFirstLoading = false;
foot.setEnabled(true);
}
public void onLoadMoreComplete( ){
onLoadMoreComplete(null);
}
public boolean dispatchTouchEvent(MotionEvent e){
//Log.e("SimplePullDownView", "dispatchTouchEvent ----------> ");
if(isFirstLoading){
return false;
}
int action;
float y = e.getY();
action = e.getAction();
if(mLongPressing && action != MotionEvent.ACTION_DOWN){
return false;
}
if(e.getAction() == MotionEvent.ACTION_DOWN){
mLongPressing = true;
}
boolean handled = true;
handled = mDetector.onTouchEvent(e);
// if(!handled)
// Log.i("SimplePullDownView", " mDetector.onTouchEvent handled = " + handled + " , mPading = " + mPading);
switch (action) {
case MotionEvent.ACTION_UP:
/*mListView.getHitRect(r);
boolean f = r.contains((int)e.getX(), (int)e.getY());*/
boolean f1 = mListView.getTop() <= e.getY() && e.getY() <= mListView.getBottom();
// Log.e("SimplePullDownView", " ACTION_UP -------> handled = " + handled + " , f1 = " + f1 + " , top == -MAX = " +(mFirstChild.getTop() == -MAX_LENGHT) );
if(!handled && mFirstChild.getTop() == -MAX_LENGHT && f1 || mState == STATE_REFRESH){
super.dispatchTouchEvent(e);
}
else{
// Log.e("SimplePullDownView", "执行释放方法 listviewDoScroll = " + listviewDoScroll);
handled = release();
}
break;
case MotionEvent.ACTION_CANCEL:
// Log.e(tag, " event: ACTION_CANCEL" );
handled = release();
super.dispatchTouchEvent(e);
break;
case MotionEvent.ACTION_DOWN:
downEvent = e;
mLongPressing = false;
// Log.e(tag, " 长按的时间间隔:" + ViewConfiguration.getLongPressTimeout());
postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout()+ 100);
mPendingRemoved = false;
downPostion = mListView.pointToPosition((int)e.getX(), (int)e.getY()) - mListView.getHeaderViewsCount();
//Log.e("SimplePullDownView", "downPostion = " + downPostion);
super.dispatchTouchEvent(e);
break;
case MotionEvent.ACTION_MOVE:
float deltaY = lastY - y;
lastY = y;
if(!mPendingRemoved){
removeCallbacks(mPendingCheckForLongPress);
mPendingRemoved = true;
}
//Log.e("SimplePullDownView","handled = " + handled + " , top = " + mFirstChild.getTop());
if(!handled && mFirstChild.getTop() == -MAX_LENGHT){
try{
return super.dispatchTouchEvent(e);
} catch (Exception e2) {
e2.printStackTrace();
return true;
}
}
else if(handled && mListView.getTop() > 0 && deltaY < 0){//deltaY小于0,向下
e.setAction(MotionEvent.ACTION_CANCEL);
super.dispatchTouchEvent(e);
}
break;
default:
break;
}
return true;
}
public void onAnimationEnd(Animation animation) {
int top = mFirstChild.getTop();
if (top < 0)
mArrow.setImageResource(R.drawable.arrow_down);
else if (top > 0)
mArrow.setImageResource(R.drawable.arrow_up);
else {
if(top < mLastTop){
mArrow.setImageResource(R.drawable.arrow_down);
} else {
mArrow.setImageResource(R.drawable.arrow_up);
}
}
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
public boolean onDown(MotionEvent e) {
return false;
}
public boolean onFling(MotionEvent motionevent, MotionEvent e,
float f, float f1) {
return false;
}
protected void onLayout(boolean flag, int i, int j, int k, int l) {
// Log.i("SimplePullDownView", "onLayout 方法执行 ------> mPading = " + mPading + " , listTop = " + (mPading + MAX_LENGHT));
int top = mPading;
int w = getMeasuredWidth();
mFirstChild.layout(0, top, w, top + MAX_LENGHT);
int h = getMeasuredHeight() + mPading + MAX_LENGHT;
mListView.layout(0, top + MAX_LENGHT , w, h);
}
public void onLongPress(MotionEvent e) {
}
/** deltaY > 0 向上*/
public boolean onScroll(MotionEvent curdown, MotionEvent cur, float deltaX, float deltaY) {
// mListView.getHitRect(r);
// Log.i("SimplePullDownView", "父亲高度 : = " + getHeight() + " , width = " + r.width() + " , height = " + r.height() + " , top = " + r.top + " , bottom = " + r.bottom);
deltaY = (float) ((double) deltaY * SCALE);
boolean handled = false;
boolean flag = false;
if (mListView.getCount() == 0) {
flag = true;
} else {
View c = mListView.getChildAt(0);
if (mListView.getFirstVisiblePosition() == 0 && c!=null && c.getTop() == 0){
flag = true;
}
// Log.i("SimplePullDownView","onScroll 方法执行 mPading = " + mPading + ", mTop = " + adapterview.getTop() + " flag = " + flag + " , deltaY = " + deltaY);
}
if (deltaY < 0F && flag || getChildAt(0).getTop() > -MAX_LENGHT){ //deltaY < 0 向下
handled = move(deltaY, false);
// Log.i("SimplePullDownView", "满足条件 执行 move 方法, handled = " + handled);
}
else
handled = false;
// Log.i("SimplePullDownView", " onScroll handled = " + handled);
return handled;
}
public void onShowPress(MotionEvent motionevent) {
}
public boolean onSingleTapUp(MotionEvent motionevent) {
return false;
}
public void setRefreshListioner(OnRefreshListioner RefreshListioner) {
mRefreshListioner = RefreshListioner;
}
public boolean isAutoLoadMore() {
return isAutoLoadMore;
}
public void setAutoLoadMore(boolean isAutoLoadMore) {
this.isAutoLoadMore = isAutoLoadMore;
if(!isAutoLoadMore){
foot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onLoadMore();
}
});
mListView.setOnScrollListener(null);
} else {
mListView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// Log.i("SimplePullDownView", "scrollState = " + scrollState);
if(isEnd && scrollState == SCROLL_STATE_IDLE && hasMore){
onLoadMore();
}
}
@Override
public void onScroll(AbsListView view, int f, int v, int t) {
// Log.i("SimplePullDownView", "first = " + f + " , visable = " + v + " , total = " + t + " , hasMore = " + hasMore);
if(f + v >= t - 1)
isEnd = true;
else
isEnd = false;
}
});
foot.setOnClickListener(null);
}
}
public void setHasMore(boolean hasMore) {
this.hasMore = hasMore;
}
public void removeFoot(){
footer_layout.removeAllViews();
}
public void addFoot(){
footer_layout.removeAllViews();
footer_layout.addView(foot);
}
public static int MAX_LENGHT = 0;
public static final int STATE_REFRESH = 1;
public static final int SCROLL_TO_CLOSE = 2;
public static final int SCROLL_TO_REFRESH = 3;
public static final double SCALE = 0.9d;
private static final int CLOSEDELAY = 300;
private static final int REFRESHDELAY = 300;
private Animation mAnimationDown;
private Animation mAnimationUp;
private ImageView mArrow;
private String mDate;
private View emptyHeaderView;
private ProgressBar mProgressBar;
private TextView more;
private ProgressBar mProgressBar2;
private int mState;
private TextView mTitle;
ListView mListView;
LinearLayout foot;
LinearLayout footer_layout;
LinearLayout header;
private GestureDetector mDetector;
private FlingRunnable mFlinger;
private int mPading;
private int mDestPading;
// private int mLastPading;
private int mLastTop;
private LinearLayout mFirstChild;
private FrameLayout mUpdateContent;
private OnRefreshListioner mRefreshListioner;
private boolean isAutoLoadMore = false;
private boolean hasMore = true;
private boolean isEnd = true;
private boolean listviewDoScroll = false;
private boolean isFirstLoading = false;
// private boolean mIsAutoScroller;
private boolean mLongPressing;//如果设置为true说明刚好到了执行长按的时间
private boolean mPendingRemoved = false;//
private String pulldowntorefresh;
private String releasetorefresh;
private String loading;
private String update_time;
Rect r = new Rect();
private int downPostion;
private MotionEvent downEvent;
private CheckForLongPress mPendingCheckForLongPress = new CheckForLongPress();
private CheckForLongPress2 mPendingCheckForLongPress2 = new CheckForLongPress2();
private float lastY;
private boolean useempty = true;
}
评论
33 楼
yunduan
2013-06-24
太给力了,求源码一份,请多指教 535266711@qq.com
32 楼
zsq2009
2013-05-09
同求一份源码,379858217@qq.com
31 楼
Android_gqs
2012-10-25
能说下国外那哥们代码在哪儿有吗??我没搜出来
30 楼
coxfilur_2008
2012-08-31
没有res里面的东西。
能把源码发给我吗?谢谢:
coxfilur@gmail.com
能把源码发给我吗?谢谢:
coxfilur@gmail.com
29 楼
icejelly_cn
2012-08-06
大神 同求一份源码学习下 谢谢您! inuyashal@163.com
28 楼
ShowTimeElaine
2012-07-27
楼主。。能加个Q么:921471769
27 楼
liuqun_567
2012-05-07
lwyr2010 写道
请问下这个offsetTopAndBottom起什么作用阿。
Offset this view's vertical location by the specified number of pixels.
26 楼
lwyr2010
2012-05-05
请问下这个offsetTopAndBottom起什么作用阿。
25 楼
wuhanliupeng
2012-04-15
liuqun_567 写道
hwg-it-eye 写道
看了您写的下拉刷新,才发觉之前我自己写的弱爆了。若方便的话,希望您能发一份源码给我参考学习下,不作其他用途。472801202@qq.com ,谢谢了~
我贴的源码是最新的,但那个例子里的代码不是最新的,我这没有最新的例子
能不能把你的代码发我一份呢, 谢谢您了的啊。 麻烦了的 79144876@qq.com
24 楼
liuqun_567
2012-04-05
hwg-it-eye 写道
看了您写的下拉刷新,才发觉之前我自己写的弱爆了。若方便的话,希望您能发一份源码给我参考学习下,不作其他用途。472801202@qq.com ,谢谢了~
我贴的源码是最新的,但那个例子里的代码不是最新的,我这没有最新的例子
23 楼
hwg-it-eye
2012-04-02
看了您写的下拉刷新,才发觉之前我自己写的弱爆了。若方便的话,希望您能发一份源码给我参考学习下,不作其他用途。472801202@qq.com ,谢谢了~
22 楼
qiujy
2012-03-27
liuqun_567 写道
qiujy 写道
新浪微博的还有一个功能,就是可以点击导航栏中的刷新来显示这个进度条。。。
这个你可以自己加啊
晕。你的代码也写得太高深了。看不太懂。嘿嘿
21 楼
liuqun_567
2012-03-19
qiujy 写道
新浪微博的还有一个功能,就是可以点击导航栏中的刷新来显示这个进度条。。。
这个你可以自己加啊
20 楼
qiujy
2012-03-19
新浪微博的还有一个功能,就是可以点击导航栏中的刷新来显示这个进度条。。。
19 楼
wuhanliupeng
2012-03-16
求源码啊。。。。。。。。。唉。。
18 楼
liuqun_567
2012-03-15
apk里的是刚开始写的,现在的是改进版的,肯定需要改一下,具体资源文件区去新浪微博客户端里扒。
17 楼
烦躁的秋千
2012-03-15
楼主给的apk运行时对的 但是上面的代码拷贝下去后,下拉出问题了
16 楼
一点触发
2012-02-22
大哥,上线的话帮小弟一下!
15 楼
一点触发
2012-02-16
大哥,最近是不是没上线?反编译后看了还是不行呀,水平实现有限呀。能不能给小弟一份源码?!
14 楼
一点触发
2012-02-15
大哥,给你发了短信。求一份源码,先谢谢啦!
发表评论
-
android 图片转 圆形和圆角矩形
2012-04-27 14:51 4694android 图片转 圆形和圆角矩形,比较高效的方法 圆角矩 ... -
android path 动画效果 (很酷)
2012-04-27 14:29 12372玩过 Path 的朋友一定会被其主页的功能按钮动画所吸引,觉得 ... -
高仿新浪微博下拉代码 公布了
2012-03-19 21:06 43高仿新浪微博下拉代码 公布了 http://liuqun-5 ... -
下拉刷新代码参考
2012-01-17 13:42 5http://liuqun-567.iteye.com/blo ... -
高仿新浪下拉刷新
2011-09-30 17:35 0自己写了个模仿新浪下拉刷新的效果。通过菜单选择 自动加载更多 ... -
android 选项卡(TabHost) 置底
2010-12-03 13:41 6735发现很多微薄如腾讯,新浪的选项卡 都是显示在页面底部的, ...
相关推荐
在Android应用开发中,"高仿新浪微博Android下拉刷新自动加载更多"是一个常见的功能需求,它结合了下拉刷新(Pull-to-Refresh)和上拉加载更多(Infinite Scrolling)两种交互模式,提升了用户体验,使得用户在滚动...
【jQuery高仿新浪微博图片显示插件】是一种基于JavaScript库jQuery实现的、旨在模仿新浪微博图片展示效果的组件。这款插件的开发灵感来源于新浪微博的图片浏览功能,它旨在为用户提供一个高度自定义且易于集成的解决...
高仿新浪微博个人主页html网站模板
【标题】:“高仿新浪微博的引导界面” 在Android应用开发中,为了提升用户体验,很多App在初次启动时会展示一个引导界面,引导用户了解应用的主要功能。本项目以“高仿新浪微博的引导界面”为主题,旨在教授如何在...
Android 毕业设计高仿新浪微博客户端,适用于大家课程设计和毕业设计。 一款独立开发的第三方新浪微博客户端,在还原了官方微博的UI的同时,加入更多不同于官方微博的新特性,给用户带来更加流畅,没有广告的体验,...
在Android开发中,"高仿新浪微博弹框菜单"是一个常见的用户界面组件,它提供了一种类似于新浪微博应用中的交互式弹出菜单。这种菜单通常在用户点击某个按钮或执行特定操作时从屏幕边缘滑出,展示一系列可选的操作或...
Android 毕业设计高仿新浪微博客户端,适用于大家课程设计和毕业设计。 一款独立开发的第三方新浪微博客户端,在还原了官方微博的UI的同时,加入更多不同于官方微博的新特性,给用户带来更加流畅,没有广告的体验,...
《记事狗高仿新浪微博 v3.0 源码解析与探讨》 在IT行业中,源码是软件开发的核心,它揭示了程序运行的内在逻辑和实现方式。本篇文章将围绕“记事狗高仿新浪微博 v3.0”的源码进行深度分析,帮助读者理解其设计思想...
在Android应用开发中,"高仿新浪微博tab"通常是指创建一个与新浪微博类似的底部导航栏,它包含多个Tab,每个Tab对应不同的功能模块,如“首页”、“发现”、“消息”和“我”的页面。这种设计模式是用户界面设计中...
html简单网页代码 高仿新浪微博访客视图,首页,发布界面等使用技术:MVVM设计模式,使用纯代码和Xib混合开发,使用SnapKit做UI布局,AFN网络数据请求,MJExtension进行字典转模型数据,使用SDWebImage进行图片加载...
【J2EE高仿新浪微博完整项目】是一个基于Java企业版(Java 2 Platform, Enterprise Edition,简称J2EE)技术的开发案例,旨在提供一个类似于新浪微博的社交网络平台的实现。这个项目涵盖了JSP(JavaServer Pages)、...
《高仿新浪微博弹框菜单——sina-popmenu开源项目解析》 在当今互联网产品中,交互设计的重要性不言而喻,而弹框菜单作为一种常见的交互元素,被广泛应用于各种应用场景,如社交网络、新闻资讯、电子商务等。在众多...