Android中ListView下拉刷新、上拉载入更多示例 listview下拉刷新demo

最关键的语句是新装载使用:

mAdapter=newArrayAdapter<String>(XListViewActivity.this,

R.layout.list_item,items);

mListView.setAdapter(mAdapter);

加载更多使用:

mAdapter.notifyDataSetChanged();

该示例使用的github上的一个开源控件XListView,作者:Maxwin-z,源码地址:https://github.com/Maxwin-z/XListView-Android

测试activity:XListViewActivity

[java] view plaincopy

packageme.maxwin;

importjava.util.ArrayList;

importme.maxwin.view.XListView;

importme.maxwin.view.XListView.IXListViewListener;

importandroid.app.Activity;

importandroid.os.Bundle;

importandroid.os.Handler;

importandroid.widget.ArrayAdapter;

publicclassXListViewActivityextendsActivityimplementsIXListViewListener{

privateXListViewmListView;

privateArrayAdapter<String>mAdapter;

privateArrayList<String>items=newArrayList<String>();

privateHandlermHandler;

privateintstart=0;

privatestaticintrefreshCnt=0;

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

geneItems();

mListView=(XListView)findViewById(R.id.xListView);

mListView.setPullLoadEnable(true);

mAdapter=newArrayAdapter<String>(this,R.layout.list_item,items);

mListView.setAdapter(mAdapter);

//mListView.setPullLoadEnable(false);

//mListView.setPullRefreshEnable(false);

mListView.setXListViewListener(this);

mHandler=newHandler();

}

privatevoidgeneItems(){

for(inti=0;i!=5;++i){

items.add("refreshcnt"+(++start));

}

}

privatevoidonLoad(){

mListView.stopRefresh();

mListView.stopLoadMore();

mListView.setRefreshTime("刚刚");

}

@Override

publicvoidonRefresh(){

mHandler.postDelayed(newRunnable(){

@Override

publicvoidrun(){

start=++refreshCnt;

items.clear();

geneItems();

//mAdapter.notifyDataSetChanged();

mAdapter=newArrayAdapter<String>(XListViewActivity.this,

R.layout.list_item,items);

mListView.setAdapter(mAdapter);

onLoad();

}

},2000);

}

@Override

publicvoidonLoadMore(){

mHandler.postDelayed(newRunnable(){

@Override

publicvoidrun(){

geneItems();

mAdapter.notifyDataSetChanged();

onLoad();

}

},2000);

}

}

控件:XListView

[java] view plaincopy

/**

*@fileXListView.java

*@packageme.maxwin.view

*@createMar18,20126:28:41PM

*@authorMaxwin

*@descriptionAnListViewsupport(a)Pulldowntorefresh,(b)Pulluptoloadmore.

*ImplementIXListViewListener,andseestopRefresh()/stopLoadMore().

*/

packageme.maxwin.view;

importme.maxwin.R;

importandroid.content.Context;

importandroid.util.AttributeSet;

importandroid.view.MotionEvent;

importandroid.view.View;

importandroid.view.ViewTreeObserver.OnGlobalLayoutListener;

importandroid.view.animation.DecelerateInterpolator;

importandroid.widget.AbsListView;

importandroid.widget.AbsListView.OnScrollListener;

importandroid.widget.ListAdapter;

importandroid.widget.ListView;

importandroid.widget.RelativeLayout;

importandroid.widget.Scroller;

importandroid.widget.TextView;

publicclassXListViewextendsListViewimplementsOnScrollListener{

privatefloatmLastY=-1;//saveeventy

privateScrollermScroller;//usedforscrollback

privateOnScrollListenermScrollListener;//user'sscrolllistener

//theinterfacetotriggerrefreshandloadmore.

privateIXListViewListenermListViewListener;

//--headerview

privateXListViewHeadermHeaderView;

//headerviewcontent,useittocalculatetheHeader'sheight.Andhideit

//whendisablepullrefresh.

privateRelativeLayoutmHeaderViewContent;

privateTextViewmHeaderTimeView;

privateintmHeaderViewHeight;//headerview'sheight

privatebooleanmEnablePullRefresh=true;

privatebooleanmPullRefreshing=false;//isrefreashing.

//--footerview

privateXListViewFootermFooterView;

privatebooleanmEnablePullLoad;

privatebooleanmPullLoading;

privatebooleanmIsFooterReady=false;

//totallistitems,usedtodetectisatthebottomoflistview.

privateintmTotalItemCount;

//formScroller,scrollbackfromheaderorfooter.

privateintmScrollBack;

privatefinalstaticintSCROLLBACK_HEADER=0;

privatefinalstaticintSCROLLBACK_FOOTER=1;

privatefinalstaticintSCROLL_DURATION=400;//scrollbackduration

privatefinalstaticintPULL_LOAD_MORE_DELTA=50;//whenpullup>=50px

//atbottom,trigger

//loadmore.

privatefinalstaticfloatOFFSET_RADIO=1.8f;//supportiOSlikepull

//feature.

/**

*@paramcontext

*/

publicXListView(Contextcontext){

super(context);

initWithContext(context);

}

publicXListView(Contextcontext,AttributeSetattrs){

super(context,attrs);

initWithContext(context);

}

publicXListView(Contextcontext,AttributeSetattrs,intdefStyle){

super(context,attrs,defStyle);

initWithContext(context);

}

privatevoidinitWithContext(Contextcontext){

mScroller=newScroller(context,newDecelerateInterpolator());

//XListViewneedthescrollevent,anditwilldispatchtheeventto

//user'slistener(asaproxy).

super.setOnScrollListener(this);

//initheaderview

mHeaderView=newXListViewHeader(context);

mHeaderViewContent=(RelativeLayout)mHeaderView

.findViewById(R.id.xlistview_header_content);

mHeaderTimeView=(TextView)mHeaderView

.findViewById(R.id.xlistview_header_time);

addHeaderView(mHeaderView);

//initfooterview

mFooterView=newXListViewFooter(context);

//initheaderheight

mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(

newOnGlobalLayoutListener(){

@Override

publicvoidonGlobalLayout(){

mHeaderViewHeight=mHeaderViewContent.getHeight();

getViewTreeObserver()

.removeGlobalOnLayoutListener(this);

}

});

}

@Override

publicvoidsetAdapter(ListAdapteradapter){

//makesureXListViewFooteristhelastfooterview,andonlyaddonce.

if(mIsFooterReady==false){

mIsFooterReady=true;

addFooterView(mFooterView);

}

super.setAdapter(adapter);

}

/**

*enableordisablepulldownrefreshfeature.

*

*@paramenable

*/

publicvoidsetPullRefreshEnable(booleanenable){

mEnablePullRefresh=enable;

if(!mEnablePullRefresh){//disable,hidethecontent

mHeaderViewContent.setVisibility(View.INVISIBLE);

}else{

mHeaderViewContent.setVisibility(View.VISIBLE);

}

}

/**

*enableordisablepulluploadmorefeature.

*

*@paramenable

*/

publicvoidsetPullLoadEnable(booleanenable){

mEnablePullLoad=enable;

if(!mEnablePullLoad){

mFooterView.hide();

mFooterView.setOnClickListener(null);

}else{

mPullLoading=false;

mFooterView.show();

mFooterView.setState(XListViewFooter.STATE_NORMAL);

//both"pullup"and"click"willinvokeloadmore.

mFooterView.setOnClickListener(newOnClickListener(){

@Override

publicvoidonClick(Viewv){

startLoadMore();

}

});

}

}

/**

*stoprefresh,resetheaderview.

*/

publicvoidstopRefresh(){

if(mPullRefreshing==true){

mPullRefreshing=false;

resetHeaderHeight();

}

}

/**

*stoploadmore,resetfooterview.

*/

publicvoidstopLoadMore(){

if(mPullLoading==true){

mPullLoading=false;

mFooterView.setState(XListViewFooter.STATE_NORMAL);

}

}

/**

*setlastrefreshtime

*

*@paramtime

*/

publicvoidsetRefreshTime(Stringtime){

mHeaderTimeView.setText(time);

}

privatevoidinvokeOnScrolling(){

if(mScrollListenerinstanceofOnXScrollListener){

OnXScrollListenerl=(OnXScrollListener)mScrollListener;

l.onXScrolling(this);

}

}

privatevoidupdateHeaderHeight(floatdelta){

mHeaderView.setVisiableHeight((int)delta

+mHeaderView.getVisiableHeight());

if(mEnablePullRefresh&&!mPullRefreshing){//未处于刷新状态,更新箭头

if(mHeaderView.getVisiableHeight()>mHeaderViewHeight){

mHeaderView.setState(XListViewHeader.STATE_READY);

}else{

mHeaderView.setState(XListViewHeader.STATE_NORMAL);

}

}

setSelection(0);//scrolltotopeachtime

}

/**

*resetheaderview'sheight.

*/

privatevoidresetHeaderHeight(){

intheight=mHeaderView.getVisiableHeight();

if(height==0)//notvisible.

return;

//refreshingandheaderisn'tshownfully.donothing.

if(mPullRefreshing&&height<=mHeaderViewHeight){

return;

}

intfinalHeight=0;//default:scrollbacktodismissheader.

//isrefreshing,justscrollbacktoshowalltheheader.

if(mPullRefreshing&&height>mHeaderViewHeight){

finalHeight=mHeaderViewHeight;

}

mScrollBack=SCROLLBACK_HEADER;

mScroller.startScroll(0,height,0,finalHeight-height,

SCROLL_DURATION);

//triggercomputeScroll

invalidate();

}

privatevoidupdateFooterHeight(floatdelta){

intheight=mFooterView.getBottomMargin()+(int)delta;

if(mEnablePullLoad&&!mPullLoading){

if(height>PULL_LOAD_MORE_DELTA){//heightenoughtoinvokeload

//more.

mFooterView.setState(XListViewFooter.STATE_READY);

}else{

mFooterView.setState(XListViewFooter.STATE_NORMAL);

}

}

mFooterView.setBottomMargin(height);

//setSelection(mTotalItemCount-1);//scrolltobottom

}

privatevoidresetFooterHeight(){

intbottomMargin=mFooterView.getBottomMargin();

if(bottomMargin>0){

mScrollBack=SCROLLBACK_FOOTER;

mScroller.startScroll(0,bottomMargin,0,-bottomMargin,

SCROLL_DURATION);

invalidate();

}

}

privatevoidstartLoadMore(){

mPullLoading=true;

mFooterView.setState(XListViewFooter.STATE_LOADING);

if(mListViewListener!=null){

mListViewListener.onLoadMore();

}

}

@Override

publicbooleanonTouchEvent(MotionEventev){

if(mLastY==-1){

mLastY=ev.getRawY();

}

switch(ev.getAction()){

caseMotionEvent.ACTION_DOWN:

mLastY=ev.getRawY();

break;

caseMotionEvent.ACTION_MOVE:

finalfloatdeltaY=ev.getRawY()-mLastY;

mLastY=ev.getRawY();

System.out.println("数据监测:"+getFirstVisiblePosition()+"---->"

+getLastVisiblePosition());

if(getFirstVisiblePosition()==0

&&(mHeaderView.getVisiableHeight()>0||deltaY>0)){

//thefirstitemisshowing,headerhasshownorpulldown.

updateHeaderHeight(deltaY/OFFSET_RADIO);

invokeOnScrolling();

}elseif(getLastVisiblePosition()==mTotalItemCount-1

&&(mFooterView.getBottomMargin()>0||deltaY<0)){

//lastitem,alreadypulleduporwanttopullup.

updateFooterHeight(-deltaY/OFFSET_RADIO);

}

break;

default:

mLastY=-1;//reset

if(getFirstVisiblePosition()==0){

//invokerefresh

if(mEnablePullRefresh

&&mHeaderView.getVisiableHeight()>mHeaderViewHeight){

mPullRefreshing=true;

mHeaderView.setState(XListViewHeader.STATE_REFRESHING);

if(mListViewListener!=null){

mListViewListener.onRefresh();

}

}

resetHeaderHeight();

}

if(getLastVisiblePosition()==mTotalItemCount-1){

//invokeloadmore.

if(mEnablePullLoad

&&mFooterView.getBottomMargin()>PULL_LOAD_MORE_DELTA){

startLoadMore();

}

resetFooterHeight();

}

break;

}

returnsuper.onTouchEvent(ev);

}

@Override

publicvoidcomputeScroll(){

if(mScroller.computeScrollOffset()){

if(mScrollBack==SCROLLBACK_HEADER){

mHeaderView.setVisiableHeight(mScroller.getCurrY());

}else{

mFooterView.setBottomMargin(mScroller.getCurrY());

}

postInvalidate();

invokeOnScrolling();

}

super.computeScroll();

}

@Override

publicvoidsetOnScrollListener(OnScrollListenerl){

mScrollListener=l;

}

@Override

publicvoidonScrollStateChanged(AbsListViewview,intscrollState){

if(mScrollListener!=null){

mScrollListener.onScrollStateChanged(view,scrollState);

}

}

@Override

publicvoidonScroll(AbsListViewview,intfirstVisibleItem,

intvisibleItemCount,inttotalItemCount){

//sendtouser'slistener

mTotalItemCount=totalItemCount;

if(mScrollListener!=null){

mScrollListener.onScroll(view,firstVisibleItem,visibleItemCount,

totalItemCount);

}

}

publicvoidsetXListViewListener(IXListViewListenerl){

mListViewListener=l;

}

/**

*youcanlistenListView.OnScrollListenerorthisone.itwillinvoke

*onXScrollingwhenheader/footerscrollback.

*/

publicinterfaceOnXScrollListenerextendsOnScrollListener{

publicvoidonXScrolling(Viewview);

}

/**

*implementsthisinterfacetogetrefresh/loadmoreevent.

*/

publicinterfaceIXListViewListener{

publicvoidonRefresh();

publicvoidonLoadMore();

}

}

XListView顶部:XListViewHeader

[java] view plaincopy

/**

*@fileXListViewHeader.java

*@createApr18,20125:22:27PM

*@authorMaxwin

*@descriptionXListView'sheader

*/

packageme.maxwin.view;

importme.maxwin.R;

importandroid.content.Context;

importandroid.util.AttributeSet;

importandroid.view.Gravity;

importandroid.view.LayoutInflater;

importandroid.view.View;

importandroid.view.animation.Animation;

importandroid.view.animation.RotateAnimation;

importandroid.widget.ImageView;

importandroid.widget.LinearLayout;

importandroid.widget.ProgressBar;

importandroid.widget.TextView;

publicclassXListViewHeaderextendsLinearLayout{

privateLinearLayoutmContainer;

privateImageViewmArrowImageView;

privateProgressBarmProgressBar;

privateTextViewmHintTextView;

privateintmState=STATE_NORMAL;

privateAnimationmRotateUpAnim;

privateAnimationmRotateDownAnim;

privatefinalintROTATE_ANIM_DURATION=180;

publicfinalstaticintSTATE_NORMAL=0;

publicfinalstaticintSTATE_READY=1;

publicfinalstaticintSTATE_REFRESHING=2;

publicXListViewHeader(Contextcontext){

super(context);

initView(context);

}

/**

*@paramcontext

*@paramattrs

*/

publicXListViewHeader(Contextcontext,AttributeSetattrs){

super(context,attrs);

initView(context);

}

privatevoidinitView(Contextcontext){

//初始情况,设置下拉刷新view高度为0

LinearLayout.LayoutParamslp=newLinearLayout.LayoutParams(

LayoutParams.MATCH_PARENT,0);

mContainer=(LinearLayout)LayoutInflater.from(context).inflate(

R.layout.xlistview_header,null);

addView(mContainer,lp);

setGravity(Gravity.BOTTOM);

mArrowImageView=(ImageView)findViewById(R.id.xlistview_header_arrow);

mHintTextView=(TextView)findViewById(R.id.xlistview_header_hint_textview);

mProgressBar=(ProgressBar)findViewById(R.id.xlistview_header_progressbar);

mRotateUpAnim=newRotateAnimation(0.0f,-180.0f,

Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,

0.5f);

mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);

mRotateUpAnim.setFillAfter(true);

mRotateDownAnim=newRotateAnimation(-180.0f,0.0f,

Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,

0.5f);

mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);

mRotateDownAnim.setFillAfter(true);

}

publicvoidsetState(intstate){

if(state==mState)

return;

if(state==STATE_REFRESHING){//显示进度

mArrowImageView.clearAnimation();

mArrowImageView.setVisibility(View.INVISIBLE);

mProgressBar.setVisibility(View.VISIBLE);

}else{//显示箭头图片

mArrowImageView.setVisibility(View.VISIBLE);

mProgressBar.setVisibility(View.INVISIBLE);

}

switch(state){

caseSTATE_NORMAL:

if(mState==STATE_READY){

mArrowImageView.startAnimation(mRotateDownAnim);

}

if(mState==STATE_REFRESHING){

mArrowImageView.clearAnimation();

}

mHintTextView.setText(R.string.xlistview_header_hint_normal);

break;

caseSTATE_READY:

if(mState!=STATE_READY){

mArrowImageView.clearAnimation();

mArrowImageView.startAnimation(mRotateUpAnim);

mHintTextView.setText(R.string.xlistview_header_hint_ready);

}

break;

caseSTATE_REFRESHING:

mHintTextView.setText(R.string.xlistview_header_hint_loading);

break;

default:

}

mState=state;

}

publicvoidsetVisiableHeight(intheight){

if(height<0)

height=0;

LinearLayout.LayoutParamslp=(LinearLayout.LayoutParams)mContainer

.getLayoutParams();

lp.height=height;

mContainer.setLayoutParams(lp);

}

publicintgetVisiableHeight(){

returnmContainer.getHeight();

}

}

XListView底部:XListViewFooter

[java] view plaincopy

/**

*@fileXFooterView.java

*@createMar31,20129:33:43PM

*@authorMaxwin

*@descriptionXListView'sfooter

*/

packageme.maxwin.view;

importme.maxwin.R;

importandroid.content.Context;

importandroid.util.AttributeSet;

importandroid.view.LayoutInflater;

importandroid.view.View;

importandroid.widget.LinearLayout;

importandroid.widget.TextView;

publicclassXListViewFooterextendsLinearLayout{

publicfinalstaticintSTATE_NORMAL=0;

publicfinalstaticintSTATE_READY=1;

publicfinalstaticintSTATE_LOADING=2;

privateContextmContext;

privateViewmContentView;

privateViewmProgressBar;

privateTextViewmHintView;

publicXListViewFooter(Contextcontext){

super(context);

initView(context);

}

publicXListViewFooter(Contextcontext,AttributeSetattrs){

super(context,attrs);

initView(context);

}

publicvoidsetState(intstate){

mHintView.setVisibility(View.INVISIBLE);

mProgressBar.setVisibility(View.INVISIBLE);

mHintView.setVisibility(View.INVISIBLE);

if(state==STATE_READY){

mHintView.setVisibility(View.VISIBLE);

mHintView.setText(R.string.xlistview_footer_hint_ready);

}elseif(state==STATE_LOADING){

mProgressBar.setVisibility(View.VISIBLE);

}else{

mHintView.setVisibility(View.VISIBLE);

mHintView.setText(R.string.xlistview_footer_hint_normal);

}

}

publicvoidsetBottomMargin(intheight){

if(height<0)

return;

LinearLayout.LayoutParamslp=(LinearLayout.LayoutParams)mContentView

.getLayoutParams();

lp.bottomMargin=height;

mContentView.setLayoutParams(lp);

}

publicintgetBottomMargin(){

LinearLayout.LayoutParamslp=(LinearLayout.LayoutParams)mContentView

.getLayoutParams();

returnlp.bottomMargin;

}

/**

*normalstatus

*/

publicvoidnormal(){

mHintView.setVisibility(View.VISIBLE);

mProgressBar.setVisibility(View.GONE);

}

/**

*loadingstatus

*/

publicvoidloading(){

mHintView.setVisibility(View.GONE);

mProgressBar.setVisibility(View.VISIBLE);

}

/**

*hidefooterwhendisablepullloadmore

*/

publicvoidhide(){

LinearLayout.LayoutParamslp=(LinearLayout.LayoutParams)mContentView

.getLayoutParams();

lp.height=0;

mContentView.setLayoutParams(lp);

}

/**

*showfooter

*/

publicvoidshow(){

LinearLayout.LayoutParamslp=(LinearLayout.LayoutParams)mContentView

.getLayoutParams();

lp.height=LayoutParams.WRAP_CONTENT;

mContentView.setLayoutParams(lp);

}

privatevoidinitView(Contextcontext){

mContext=context;

LinearLayoutmoreView=(LinearLayout)LayoutInflater.from(mContext)

.inflate(R.layout.xlistview_footer,null);

addView(moreView);

moreView.setLayoutParams(newLinearLayout.LayoutParams(

LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));

mContentView=moreView.findViewById(R.id.xlistview_footer_content);

mProgressBar=moreView.findViewById(R.id.xlistview_footer_progressbar);

mHintView=(TextView)moreView

.findViewById(R.id.xlistview_footer_hint_textview);

}

}

布局xml文件:

测试activity布局main:

[java] view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#f0f0f0"

android:orientation="vertical">

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/hello"/>

<me.maxwin.view.XListView

android:id="@+id/xListView"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:cacheColorHint="#00000000">

</me.maxwin.view.XListView>

</LinearLayout>

ListView每一行的布局list_item:

[html] view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<TextViewxmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/list_item_textview"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:padding="5dp"

android:textColor="#000"

android:textSize="16sp">

</TextView>

xlistview_footer.xml:

[html] view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="wrap_content">

<RelativeLayout

android:id="@+id/xlistview_footer_content"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:padding="10dp">

<ProgressBar

android:id="@+id/xlistview_footer_progressbar"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerInParent="true"

android:visibility="invisible"/>

<TextView

android:id="@+id/xlistview_footer_hint_textview"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerInParent="true"

android:text="@string/xlistview_footer_hint_normal"/>

</RelativeLayout>

</LinearLayout>

xlistview_header.xml:

[html] view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:gravity="bottom">

<RelativeLayout

android:id="@+id/xlistview_header_content"

android:layout_width="fill_parent"

android:layout_height="60dp">

<LinearLayout

android:id="@+id/xlistview_header_text"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerInParent="true"

android:gravity="center"

android:orientation="vertical">

<TextView

android:id="@+id/xlistview_header_hint_textview"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/xlistview_header_hint_normal"/>

<LinearLayout

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginTop="3dp">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/xlistview_header_last_time"

android:textSize="12sp"/>

<TextView

android:id="@+id/xlistview_header_time"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textSize="12sp"/>

</LinearLayout>

</LinearLayout>

<ImageView

android:id="@+id/xlistview_header_arrow"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@id/xlistview_header_text"

android:layout_centerVertical="true"

android:layout_marginLeft="-35dp"

android:src="@drawable/xlistview_arrow"/>

<ProgressBar

android:id="@+id/xlistview_header_progressbar"

android:layout_width="30dp"

android:layout_height="30dp"

android:layout_alignLeft="@id/xlistview_header_text"

android:layout_centerVertical="true"

android:layout_marginLeft="-40dp"

android:visibility="invisible"/>

</RelativeLayout>

</LinearLayout>

strings.xml:

[html] view plaincopy

<?xmlversion="1.0"encoding="utf-8"?>

<resources>

<stringname="hello">HelloWorld,XListViewActivity!</string>

<stringname="app_name">XListView</string>

<stringname="xlistview_header_hint_normal">下拉刷新</string>

<stringname="xlistview_header_hint_ready">松开刷新数据</string>

<stringname="xlistview_header_hint_loading">正在加载...</string>

<stringname="xlistview_header_last_time">上次更新时间:</string>

<stringname="xlistview_footer_hint_normal">查看更多</string>

<stringname="xlistview_footer_hint_ready">松开载入更多</string>

Android中ListView下拉刷新、上拉载入更多示例 listview下拉刷新demo
</resources>

图片资源:

  

爱华网本文地址 » http://www.aihuau.com/a/25101011/51929.html

更多阅读

word中向下的箭头怎么打出来? word向下箭头怎么去掉

word中向下的箭头怎么打出来?——简介在日常工作中,我们常常要用到箭头符号,哪么在word中向下的箭头怎么打来呢?下面跟随小编一起去看看:向下的箭头怎么打吧?word中向下的箭头怎么打出来?——向下的箭头怎么打方法:

如何在Word中输入平均数的符号X上加一横X拔 算术平均数符号

如何在Word中输入平均数的符号X上加一横(X拔)——简介在我们常用的公式中平均数的基本都是用X的上面加一根横杠来表示,念作“X拔”。它十分常用,但是在我们用Word书写论文过程中,往往不知道如何在Word中输入这个符号,下面我就介绍一下如何

解放军集结中缅边境孟定、南伞一带待命 云南孟定

解放军集结中缅边境孟定、南伞一带待命图片来源:xiao_qiuyan的博客http://blog.sina.com.cn/s/blog_3ddb38190102v9wm.html自2015年3月14日中央军委副席范长龙电话警告敏昂莱要管好缅军部队后, 3月14日,15日,中国重兵陆续集结孟定,南伞

转载 辨伪影视小说中关于雍正蒸人、炸人的问题 瓷器辨伪

我真的很想对那些乱评乱写雍正的人说评价历史人物也同样要个客观公正同样是要凭良心负责任的励精图治一世不容易雍正狠是狠但雍正那是对官狠几时见他对百姓狠过?看看雍正的悦心集就能知道他为人处世的准则了个人认为二月河笔下的雍正

声明:《Android中ListView下拉刷新、上拉载入更多示例 listview下拉刷新demo》为网友别低头分享!如侵犯到您的合法权益请联系我们删除