ListVIEw 控件可使用四种不同视图显示项目。通过此控件,可将项目组成带有或不带有列标头的列,并显示伴随的图标和文本。
可使用 ListVIEw 控件将称作 ListItem 对象的列表条目组织成下列四种不同的视图之一:1.大(标准)图标2.小图标3.列表4.报表 VIEw 属性决定在列表中控件使用何种视图显示项目。
还可用 LabelWrap 属性控制列表中与项目关联的标签是否可换行显示。另外,还可管理列表中项目的排序方法和选定项目的外观。
相信有很人做的项目估计都用的到这个。就是ListVIEw的下拉刷新上拉加载还有就是列的横向滚动;
PS:横向滚动带表头与固定列(相信蛮多人都有这样的需求吧?就是在ListVIEw上支持很多列,然而设备屏幕宽度有限)
PS:这是我个人在网上找的两个示例demo结合而成的一个示例demo,还可以继续拓展,后续有时间就会更新,大家互相学习
ListVIEw下拉刷新上拉加载示例demo原文出处:
https://www.oudahe.com/p/16392/
ListVIEw的横向滚动(带表头与固定列)示例demo原文出处:
https://www.oudahe.com/p/16409/
接下来就是晒一下项目列表图
java代码
布局文件xml
效果图:
横向滚动过的图和下拉刷新,由于不会弄动态图只能这样了
下拉刷新
刷新中
上拉加载
接下来就是上代码了,请往下看
这是自定义重写了ListVIEw控件autoListVIEw.java
package com.example.testListvIEw.Widget;import java.text.SimpleDateFormat;import java.util.Date;import java.util.Locale;import com.example.testListvIEw.R;import androID.content.Context;import androID.util.AttributeSet;import androID.vIEw.LayoutInflater;import androID.vIEw.MotionEvent;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import androID.vIEw.animation.linearInterpolator;import androID.vIEw.animation.RotateAnimation;import androID.Widget.AbsListVIEw;import androID.Widget.ImageVIEw;import androID.Widget.Progressbar;import androID.Widget.TextVIEw;import androID.Widget.AbsListVIEw.OnScrollListener;import androID.Widget.ListVIEw;/*** @author * @create* @version 1.0* @desc 自定义ListvIEw�?下拉刷新,上拉加载更多*/public class autoListVIEw extends ListVIEw implements OnScrollListener {// 区分当前 *** 作是刷新还是加�?public static final int REFRESH = 0;public static final int LOAD = 1;// 区分PulL和RELEASE的距离的大小private static final int SPACE = 20;// 定义header的四种状态和当前状�??private static final int NONE = 0;private static final int PulL = 1;private static final int RELEASE = 2;private static final int REFRESHING = 3;private int state;private LayoutInflater inflater;private VIEw header;private VIEw footer;private TextVIEw tip;private TextVIEw lastUpdate;private ImageVIEw arrow;private Progressbar refreshing;private TextVIEw noData;private TextVIEw loadFull;private TextVIEw more;private Progressbar loading;private RotateAnimation animation;private RotateAnimation reverseAnimation;private int startY;private int firstVisibleItem;private int scrollState;private int headerContentinitialHeight;private int headerContentHeight;// 只有在ListvIEw第一个item显示的时候(ListvIEw滑到了顶部)才进行下拉刷新, 否则此时的下拉只是滑动ListvIEwprivate boolean isRecorded;private boolean isLoading;// 判断是否正在加载private boolean loadEnable = true;// �?启或者关闭加载更多功�?private boolean isLoadFull;private int pageSize = 10;private OnRefreshListener onRefreshListener;private OnLoadListener onLoadListener;public autoListVIEw(Context context) {super(context);initVIEw(context);}public autoListVIEw(Context context,AttributeSet attrs) {super(context,attrs);initVIEw(context);}public autoListVIEw(Context context,AttributeSet attrs,int defStyle) {super(context,attrs,defStyle);initVIEw(context);}// 下拉刷新监听public voID setonRefreshListener(OnRefreshListener onRefreshListener) {this.onRefreshListener = onRefreshListener;}// 加载更多监听public voID setonLoadListener(OnLoadListener onLoadListener) {this.loadEnable = true;this.onLoadListener = onLoadListener;}public boolean isLoadEnable() {return loadEnable;}// 这里的开启或者关闭加载更多,并不支持动�?�调�?public voID setLoadEnable(boolean loadEnable) {this.loadEnable = loadEnable;this.removeFooterVIEw(footer);}public int getPageSize() {return pageSize;}public voID setPageSize(int pageSize) {this.pageSize = pageSize;}// 初始化组�?private voID initVIEw(Context context) {// 设置箭头特效animation = new RotateAnimation(0,-180,RotateAnimation.relative_TO_SELF,0.5f,0.5f);animation.setInterpolator(new linearInterpolator());animation.setDuration(1000);animation.setFillAfter(true);reverseAnimation = new RotateAnimation(-180,0.5f);reverseAnimation.setInterpolator(new linearInterpolator());reverseAnimation.setDuration(1000);reverseAnimation.setFillAfter(true);inflater = LayoutInflater.from(context);footer = inflater.inflate(R.layout.ListvIEw_footer,null);loadFull = (TextVIEw) footer.findVIEwByID(R.ID.loadFull);noData = (TextVIEw) footer.findVIEwByID(R.ID.noData);more = (TextVIEw) footer.findVIEwByID(R.ID.more);loading = (Progressbar) footer.findVIEwByID(R.ID.loading);header = inflater.inflate(R.layout.pull_to_refresh_header,null);arrow = (ImageVIEw) header.findVIEwByID(R.ID.arrow);tip = (TextVIEw) header.findVIEwByID(R.ID.tip);lastUpdate = (TextVIEw) header.findVIEwByID(R.ID.lastUpdate);refreshing = (Progressbar) header.findVIEwByID(R.ID.refreshing);// 为ListvIEw添加头部和尾部,并进行初始化headerContentinitialHeight = header.getpaddingtop();measureVIEw(header);headerContentHeight = header.getMeasuredHeight();toppadding(-headerContentHeight);this.addheaderVIEw(header);this.addFooterVIEw(footer);this.setonScrollListener(this);}public voID onRefresh() {if (onRefreshListener != null) {onRefreshListener.onRefresh();}}public voID onLoad() {if (onLoadListener != null) {onLoadListener.onLoad();}}public voID onRefreshComplete(String updateTime) {lastUpdate.setText(this.getContext().getString(R.string.lastUpdateTime,getCurrentTime()));state = NONE;refreshheaderVIEwByState();}// 用于下拉刷新结束后的回调public voID onRefreshComplete() {String currentTime = getCurrentTime();onRefreshComplete(currentTime);}// 用于加载更多结束后的回调public voID onLoadComplete() {isLoading = false;}@OverrIDepublic voID onScroll(AbsListVIEw vIEw,int firstVisibleItem,int visibleItemCount,int totalitemCount) {this.firstVisibleItem = firstVisibleItem;}@OverrIDepublic voID onScrollStateChanged(AbsListVIEw vIEw,int scrollState) {this.scrollState = scrollState;ifNeedLoad(vIEw,scrollState);}// 根据ListvIEw滑动的状态判断是否需要加载更�?private voID ifNeedLoad(AbsListVIEw vIEw,int scrollState) {if (!loadEnable) {return;}try {if (scrollState == OnScrollListener.SCRolL_STATE_IDLE && !isLoading&& vIEw.getLastVisibleposition() == vIEw.getpositionForVIEw(footer) && !isLoadFull) {onLoad();isLoading = true;}} catch (Exception e) {}}/*** 监听触摸事件,解读手�?*/@OverrIDepublic boolean ontouchEvent(MotionEvent ev) {switch (ev.getAction()) {// case MotionEvent.ACTION_DOWN:// if (firstVisibleItem == 0) {// isRecorded = true;// startY = (int) ev.getY();// }// break;case MotionEvent.ACTION_CANCEL:case MotionEvent.ACTION_UP:if (state == PulL) {state = NONE;refreshheaderVIEwByState();} else if (state == RELEASE) {state = REFRESHING;refreshheaderVIEwByState();onRefresh();}isRecorded = false;break;case MotionEvent.ACTION_MOVE:whenMove(ev);break;}return super.ontouchEvent(ev);}@OverrIDepublic boolean onIntercepttouchEvent(MotionEvent ev) {if (ev.getAction() == MotionEvent.ACTION_DOWN) {if (firstVisibleItem == 0) {isRecorded = true;startY = (int) ev.getY();}}return super.onIntercepttouchEvent(ev);}// 解读手势,刷新header状�??private voID whenMove(MotionEvent ev) {if (!isRecorded) {return;}int tmpY = (int) ev.getY();int space = tmpY - startY;int toppadding = space - headerContentHeight;switch (state) {case NONE:if (space > 0) {state = PulL;refreshheaderVIEwByState();}break;case PulL:toppadding(toppadding);if (scrollState == SCRolL_STATE_touch_SCRolL && space > headerContentHeight + SPACE) {state = RELEASE;refreshheaderVIEwByState();}break;case RELEASE:toppadding(toppadding);if (space > 0 && space < headerContentHeight + SPACE) {state = PulL;refreshheaderVIEwByState();} else if (space <= 0) {state = NONE;refreshheaderVIEwByState();}break;}}// 调整header的大小�?�其实调整的只是距离顶部的高度�??private voID toppadding(int toppadding) {header.setpadding(header.getpaddingleft(),toppadding,header.getpaddingRight(),header.getpaddingBottom());header.invalIDate();}/*** 这个方法是根据结果的大小来决定footer显示的�??* <p>* 这里假定每次请求的条数为10。如果请求到�?10条�?�则认为还有数据。如过结果不�?10条,则认为数据已经全部加载,* 这时footer显示已经全部加载* </p>* * @param resultSize*/public voID setResultSize(int resultSize) {if (resultSize == 0) {isLoadFull = true;loadFull.setVisibility(VIEw.GONE);loading.setVisibility(VIEw.GONE);more.setVisibility(VIEw.GONE);noData.setVisibility(VIEw.VISIBLE);} else if (resultSize > 0 && resultSize < pageSize) {isLoadFull = true;loadFull.setVisibility(VIEw.VISIBLE);loading.setVisibility(VIEw.GONE);more.setVisibility(VIEw.GONE);noData.setVisibility(VIEw.GONE);} else if (resultSize == pageSize) {isLoadFull = false;loadFull.setVisibility(VIEw.GONE);loading.setVisibility(VIEw.VISIBLE);more.setVisibility(VIEw.VISIBLE);noData.setVisibility(VIEw.GONE);}}// 根据当前状�?�,调整headerprivate voID refreshheaderVIEwByState() {switch (state) {case NONE:toppadding(-headerContentHeight);tip.setText(R.string.pull_to_refresh);refreshing.setVisibility(VIEw.GONE);arrow.clearanimation();arrow.setimageResource(R.drawable.pull_to_refresh_arrow);break;case PulL:arrow.setVisibility(VIEw.VISIBLE);tip.setVisibility(VIEw.VISIBLE);lastUpdate.setVisibility(VIEw.VISIBLE);refreshing.setVisibility(VIEw.GONE);tip.setText(R.string.pull_to_refresh);arrow.clearanimation();arrow.setAnimation(reverseAnimation);break;case RELEASE:arrow.setVisibility(VIEw.VISIBLE);tip.setVisibility(VIEw.VISIBLE);lastUpdate.setVisibility(VIEw.VISIBLE);refreshing.setVisibility(VIEw.GONE);tip.setText(R.string.pull_to_refresh);tip.setText(R.string.release_to_refresh);arrow.clearanimation();arrow.setAnimation(animation);break;case REFRESHING:toppadding(headerContentinitialHeight);refreshing.setVisibility(VIEw.VISIBLE);arrow.clearanimation();arrow.setVisibility(VIEw.GONE);tip.setVisibility(VIEw.GONE);lastUpdate.setVisibility(VIEw.GONE);break;}}// 用来计算header大小的�?�比较隐晦�?�因为header的初始高度就�?0,貌似可以不用�?private voID measureVIEw(VIEw child) {VIEwGroup.LayoutParams p = child.getLayoutParams();if (p == null) {p = new VIEwGroup.LayoutParams(VIEwGroup.LayoutParams.MATCH_PARENT,VIEwGroup.LayoutParams.WRAP_CONTENT);}int chilDWIDthSpec = VIEwGroup.getChildMeasureSpec(0,0 + 0,p.wIDth);int lpHeight = p.height;int childHeightSpec;if (lpHeight > 0) {childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight,MeasureSpec.EXACTLY);} else {childHeightSpec = MeasureSpec.makeMeasureSpec(0,MeasureSpec.UnspecIFIED);}child.measure(chilDWIDthSpec,childHeightSpec);}/** 定义下拉刷新接口*/public interface OnRefreshListener {public voID onRefresh();}/** 定义加载更多接口*/public interface OnLoadListener {public voID onLoad();}public String getCurrentTime(String format) {Date date = new Date();SimpleDateFormat sdf = new SimpleDateFormat(format,Locale.getDefault());String currentTime = sdf.format(date);return currentTime;}public String getCurrentTime() {return getCurrentTime("yyyy-MM-dd HH:mm:ss");}}
这是自定义horizontalscrollview的重写 CHScrollVIEw.java
package com.example.testListvIEw.Widget;import java.util.ArrayList;import java.util.List;import com.example.testListvIEw.Widget.CHScrollVIEw.CHScrollVIEwHelper;import androID.content.Context;import androID.util.AttributeSet;import androID.util.Log;import androID.vIEw.MotionEvent;import androID.Widget.horizontalscrollview;import androID.Widget.Toast;public class CHScrollVIEw extends horizontalscrollview {private Context context;float startx = 0;float offset;public CHScrollVIEw(Context context,defStyle);this.context = context;}public CHScrollVIEw(Context context,attrs);this.context = context;}public CHScrollVIEw(Context context) {super(context);this.context = context;}@OverrIDepublic boolean ontouchEvent(MotionEvent ev) {// 进行触摸赋值CHScrollVIEwHelper.mtouchVIEw = this;return super.ontouchEvent(ev);}@OverrIDeprotected voID onScrollChanged(int l,int t,int oldl,int oldt) {// 当当前的CHSCrollVIEw被触摸时,滑动其它if (CHScrollVIEwHelper.mtouchVIEw == this) {onScrollChanged(l,t,oldl,oldt,0);} else {super.onScrollChanged(l,oldt);}}public voID onScrollChanged(int l,int oldt,int none) {for (CHScrollVIEw scrollVIEw : CHScrollVIEwHelper.mHScrollVIEws) {// 防止重复滑动if (CHScrollVIEwHelper.mtouchVIEw != scrollVIEw)scrollVIEw.smoothScrollTo(l,t);}}public static class CHScrollVIEwHelper {public static horizontalscrollview mtouchVIEw;public static List<CHScrollVIEw> mHScrollVIEws = new ArrayList<CHScrollVIEw>();public static voID addHVIEws(final CHScrollVIEw hScrollVIEw,autoListVIEw autoListVIEw) {if (!CHScrollVIEwHelper.mHScrollVIEws.isEmpty()) {int size = CHScrollVIEwHelper.mHScrollVIEws.size();CHScrollVIEw scrollVIEw = CHScrollVIEwHelper.mHScrollVIEws.get(size - 1);final int scrollX = scrollVIEw.getScrollX();// 第一次满屏后,向下滑动,有一条数据在开始时未加入if (scrollX != 0) {autoListVIEw.post(new Runnable() {@OverrIDepublic voID run() {// 当ListVIEw刷新完成之后,把该条移动到最终位置hScrollVIEw.scrollTo(scrollX,0);}});}}CHScrollVIEwHelper.mHScrollVIEws.add(hScrollVIEw);}}}
这是ListVIEw的适配器adapter,ListVIEwScrollAdapter.java
package com.example.testListvIEw.adapter;import java.util.List;import java.util.Map;import com.example.testListvIEw.R;import com.example.testListvIEw.Widget.autoListVIEw;import com.example.testListvIEw.Widget.CHScrollVIEw;import com.example.testListvIEw.Widget.CHScrollVIEw.CHScrollVIEwHelper;import androID.content.Context;import androID.vIEw.LayoutInflater;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import androID.Widget.SimpleAdapter;import androID.Widget.TextVIEw;public class ListVIEwScrollAdapter extends SimpleAdapter {private List<? extends Map<String,?>> datas;private int res;private String[] from;private int[] to;private Context context;private int resScroll;private autoListVIEw lstv;public ListVIEwScrollAdapter(Context context,List<? extends Map<String,?>> data,int resource,String[] from,int[] to,int resourceItem,autoListVIEw autoListVIEw) {super(context,data,resource,from,to);this.context = context;this.datas = data;this.res = resource;this.from = from;this.to = to;this.resScroll = resourceItem;this.lstv = autoListVIEw;}@OverrIDepublic int getCount() {return this.datas.size();}@OverrIDepublic VIEw getVIEw(int position,VIEw convertVIEw,VIEwGroup parent) {VIEw v = convertVIEw;if (v == null) {v = LayoutInflater.from(context).inflate(res,null);// 第一次初始化的时候装进来CHScrollVIEwHelper.addHVIEws((CHScrollVIEw) v.findVIEwByID(resScroll),lstv);VIEw[] vIEws = new VIEw[to.length];for (int i = 0; i < to.length; i++) {VIEw tv = v.findVIEwByID(to[i]);vIEws[i] = tv;}v.setTag(vIEws);}v.setBackgroundResource(R.drawable.selector_bg_white_gray);VIEw[] holders = (VIEw[]) v.getTag();int len = holders.length;for (int i = 0; i < len; i++) {((TextVIEw) holders[i]).setText(this.datas.get(position).get(from[i]).toString());}return v;}public Context getContext() {return context;}}
这是MainActivity.java
package com.example.testListvIEw;import androID.os.Bundle;import androID.os.Handler;import androID.os.Message;import androID.vIEw.VIEw;import androID.Widget.AdapterVIEw.OnItemClickListener;import androID.Widget.AdapterVIEw;import androID.Widget.TextVIEw;import androID.Widget.Toast;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import com.example.testListvIEw.Widget.autoListVIEw.OnLoadListener;import com.example.testListvIEw.Widget.autoListVIEw.OnRefreshListener;import com.example.testListvIEw.R;import com.example.testListvIEw.adapter.ListVIEwScrollAdapter;import com.example.testListvIEw.Widget.autoListVIEw;import com.example.testListvIEw.Widget.CHScrollVIEw;import com.example.testListvIEw.Widget.CHScrollVIEw.CHScrollVIEwHelper;import androID.annotation.Suppresslint;import androID.app.Activity;public class MainActivity extends Activity implements OnRefreshListener,OnLoadListener,OnItemClickListener {private autoListVIEw lstv;private CHScrollVIEw headerScroll;List<Map<String,String>> List = new ArrayList<Map<String,String>>();private ListVIEwScrollAdapter adapter;@Suppresslint("HandlerLeak")private Handler handler = new Handler() {@SuppressWarnings("unchecked")public voID handleMessage(Message msg) {List<Map<String,String>> result = (List<Map<String,String>>) msg.obj;switch (msg.what) {case autoListVIEw.REFRESH:lstv.onRefreshComplete();List.clear();List.addAll(result);break;case autoListVIEw.LOAD:lstv.onLoadComplete();List.addAll(result);break;}lstv.setResultSize(result.size());adapter.notifyDataSetChanged();};};@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentVIEw(R.layout.activity_main);initVIEw();initData();}private voID initVIEw() {headerScroll = (CHScrollVIEw) findVIEwByID(R.ID.item_scroll_Title);CHScrollVIEwHelper.mHScrollVIEws.clear();// 添加头滑动事件CHScrollVIEwHelper.mHScrollVIEws.add(headerScroll);lstv = (autoListVIEw) findVIEwByID(R.ID.scroll_List);adapter = new ListVIEwScrollAdapter(this,List,R.layout.auto_ListvIEw_item,new String[] { "Title","data_1","data_2","data_3","data_4","data_5","data_6",},new int[] { R.ID.item_Title,R.ID.item_data1,R.ID.item_data2,R.ID.item_data3,R.ID.item_data4,R.ID.item_data5,R.ID.item_data6 },R.ID.item_scroll,lstv);lstv.setAdapter(adapter);lstv.setonRefreshListener(this);lstv.setonLoadListener(this);lstv.setonItemClickListener(this);}private voID initData() {loadData(autoListVIEw.REFRESH);}private voID loadData(final int what) {// 这里模拟从服务器获取数据new Thread(new Runnable() {@OverrIDepublic voID run() {try {Thread.sleep(700);} catch (InterruptedException e) {e.printstacktrace();}Message msg = handler.obtainMessage();msg.what = what;msg.obj = getData();handler.sendMessage(msg);}}).start();}@OverrIDepublic voID onRefresh() {loadData(autoListVIEw.REFRESH);}@OverrIDepublic voID onLoad() {loadData(autoListVIEw.LOAD);}@OverrIDepublic voID onItemClick(AdapterVIEw<?> arg0,VIEw arg1,int arg2,long arg3) {try {TextVIEw textVIEw = (TextVIEw) arg1.findVIEwByID(R.ID.item_data2);Toast.makeText(this,"你点击了:" + textVIEw.getText(),Toast.LENGTH_SHORT).show();} catch (Exception ex) {}}// 测试数据public List<Map<String,String>> getData() {List<Map<String,String>> result = new ArrayList<Map<String,String>>();Map<String,String> data = null;for (int i = 0; i < 10; i++) {data = new HashMap<String,String>();data.put("Title","Title_" + i);data.put("data_" + 1,"Date_" + 1 + "_" + i);data.put("data_" + 2,"Date_" + 2 + "_" + i);data.put("data_" + 3,"Date_" + 3 + "_" + i);data.put("data_" + 4,"Date_" + 4 + "_" + i);data.put("data_" + 5,"Date_" + 5 + "_" + i);data.put("data_" + 6,"Date_" + 6 + "_" + i);result.add(data);}return result;}}
这是layout布局文件 activity_main.xml
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:orIEntation="vertical" ><linearLayoutandroID:layout_wIDth="fill_parent"androID:layout_height="wrap_content"androID:background="#ccc"androID:minHeight="40dip"androID:orIEntation="horizontal" ><TextVIEwandroID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:layout_weight="2"androID:gravity="center"androID:text="表头测试"androID:textcolor="#850" /><com.example.testListvIEw.Widget.CHScrollVIEwandroID:ID="@+ID/item_scroll_Title"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:layout_weight="1"androID:scrollbars="none" ><linearLayoutandroID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:orIEntation="horizontal" ><TextVIEwandroID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:text="Date1"androID:textcolor="#850" /><TextVIEwandroID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:text="Date2"androID:textcolor="#850" /><TextVIEwandroID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:text="Date3"androID:textcolor="#850" /><TextVIEwandroID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:text="Date4"androID:textcolor="#850" /><TextVIEwandroID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:text="Date5"androID:textcolor="#850" /><TextVIEwandroID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:text="Date6"androID:textcolor="#850" /></linearLayout></com.example.testListvIEw.Widget.CHScrollVIEw></linearLayout><com.example.testListvIEw.Widget.autoListVIEwandroID:ID="@+ID/scroll_List"androID:layout_wIDth="match_parent"androID:layout_height="fill_parent"androID:cachecolorHint="@androID:color/transparent" /></linearLayout>
auto_ListvIEw_item.xml布局文件 ListVIEw的item布局文件
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:descendantFocusability="blocksDescendants"androID:minHeight="50dip"androID:orIEntation="horizontal" ><TextVIEwandroID:ID="@+ID/item_Title"androID:layout_wIDth="fill_parent"androID:layout_height="match_parent"androID:layout_weight="2"androID:gravity="center"androID:text="表头测试" /><com.example.testListvIEw.Widget.CHScrollVIEwandroID:ID="@+ID/item_scroll"androID:layout_wIDth="fill_parent"androID:layout_height="match_parent"androID:layout_weight="1"androID:focusable="false"androID:scrollbars="none" ><linearLayoutandroID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:orIEntation="horizontal" ><TextVIEwandroID:ID="@+ID/item_data1"androID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:textcolor="#011" /><TextVIEwandroID:ID="@+ID/item_data2"androID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:textcolor="#191" /><TextVIEwandroID:ID="@+ID/item_data3"androID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:textcolor="#101" /><TextVIEwandroID:ID="@+ID/item_data4"androID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:textcolor="#111" /><TextVIEwandroID:ID="@+ID/item_data5"androID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:textcolor="#071" /><TextVIEwandroID:ID="@+ID/item_data6"androID:layout_wIDth="100dip"androID:layout_height="fill_parent"androID:gravity="center"androID:textcolor="#910" /></linearLayout></com.example.testListvIEw.Widget.CHScrollVIEw></linearLayout>
ListvIEw底部提示正在加载中的布局文件 ListvIEw_footer.xml
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="match_parent"androID:layout_height="wrap_content"androID:gravity="center"androID:orIEntation="horizontal" ><TextVIEwandroID:ID="@+ID/loadFull"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:gravity="center"androID:padding="5dp"androID:text="@string/load_full"androID:visibility="gone" /><TextVIEwandroID:ID="@+ID/noData"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:gravity="center"androID:padding="5dp"androID:text="@string/no_data"androID:visibility="gone" /><TextVIEwandroID:ID="@+ID/more"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:gravity="center"androID:padding="5dp"androID:text="@string/more" /><ProgressbarandroID:ID="@+ID/loading" /></linearLayout>
ListVIEw顶部提示下拉刷新的一些状态布局xml文件 pull_to_refresh_header.xml
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"androID:gravity="center"androID:orIEntation="vertical" ><relativeLayoutandroID:layout_wIDth="match_parent"androID:layout_height="wrap_content"androID:paddingBottom="5dp" ><linearLayoutandroID:ID="@+ID/layout"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:layout_centerHorizontal="true"androID:layout_centerVertical="true"androID:orIEntation="vertical" ><ProgressbarandroID:ID="@+ID/refreshing" /><TextVIEwandroID:ID="@+ID/tip"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:layout_gravity="center" /><TextVIEwandroID:ID="@+ID/lastUpdate"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:layout_gravity="center"androID:textSize="12sp" /></linearLayout><ImageVIEwandroID:ID="@+ID/arrow"androID:layout_wIDth="wrap_content"androID:layout_height="wrap_content"androID:layout_centerVertical="true"androID:layout_marginRight="20dp"androID:layout_toleftOf="@ID/layout"androID:contentDescription="@string/d"androID:src="@drawable/pull_to_refresh_arrow" /></relativeLayout><ImageVIEwandroID:layout_wIDth="match_parent"androID:layout_height="wrap_content"androID:background="@drawable/h_line"androID:contentDescription="@string/d" /></linearLayout><uses-sdkandroID:minSdkVersion="8"androID:targetSdkVersion="15" />
AndroID编译和目标版本是4.0.3
以上所述是小编给大家介绍的AndroID开发ListVIEw中下拉刷新上拉加载及带列的横向滚动实现方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程小技巧网站的支持!
总结以上是内存溢出为你收集整理的Android开发ListView中下拉刷新上拉加载及带列的横向滚动实现方法全部内容,希望文章能够帮你解决Android开发ListView中下拉刷新上拉加载及带列的横向滚动实现方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)