PinnedHeaderListView实现删除

项目中用到四个List集合展示一个页面,并且每个页面都会有一个标题栏.找了半天资料决定用PinnedHeaderListView开源项目.最后需求又来了,需要一个删除的功能,又去网上找资料,发现没有实现删除的demo,于是自己把PinnedHeaderListView源码分析了下,其实也就一个类.下面我贴上代码,希望后面的朋友少走弯路.

PinnedHeaderListView   实现滚动,重绘,添加回调函数

  1. import android.content.Context;  
  2. import android.graphics.Canvas;  
  3. import android.util.AttributeSet;  
  4. import android.view.View;  
  5. import android.view.ViewGroup;  
  6. import android.widget.*;  
  7. import android.widget.AbsListView.OnScrollListener;  
  8.   
  9. public class PinnedHeaderListView extends ListView implements OnScrollListener{  
  10.   
  11.     private OnScrollListener mOnScrollListener;  
  12.   
  13.     public static interface PinnedSectionedHeaderAdapter {  
  14.         public boolean isSectionHeader(int position);  
  15.   
  16.         public int getSectionForPosition(int position);  
  17.   
  18.         public View getSectionHeaderView(int section, View convertView, ViewGroup parent);  
  19.   
  20.         public int getSectionHeaderViewType(int section);  
  21.   
  22.         public int getCount();  
  23.   
  24.     }  
  25.   
  26.     private PinnedSectionedHeaderAdapter mAdapter;  
  27.     private View mCurrentHeader;  
  28.     private int mCurrentHeaderViewType = 0;  
  29.     private float mHeaderOffset;  
  30.     private boolean mShouldPin = true;  
  31.     private int mCurrentSection = 0;  
  32.     private int mWidthMode;  
  33.     private int mHeightMode;  
  34.   
  35.     public PinnedHeaderListView(Context context) {  
  36.         super(context);  
  37.         super.setOnScrollListener(this);  
  38.     }  
  39.   
  40.     public PinnedHeaderListView(Context context, AttributeSet attrs) {  
  41.         super(context, attrs);  
  42.         super.setOnScrollListener(this);  
  43.     }  
  44.   
  45.     public PinnedHeaderListView(Context context, AttributeSet attrs, int defStyle) {  
  46.         super(context, attrs, defStyle);  
  47.         super.setOnScrollListener(this);  
  48.     }  
  49.   
  50.     public void setPinHeaders(boolean shouldPin) {  
  51.         mShouldPin = shouldPin;  
  52.     }  
  53.   
  54.     @Override  
  55.     public void setAdapter(ListAdapter adapter) {  
  56.         mCurrentHeader = null;  
  57.         mAdapter = (PinnedSectionedHeaderAdapter) adapter;  
  58.         super.setAdapter(adapter);  
  59.     }  
  60.   
  61.     @Override  
  62.     public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {  
  63.         if (mOnScrollListener != null) {  
  64.             mOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);  
  65.         }  
  66.   
  67.         if (mAdapter == null || mAdapter.getCount() == 0 || !mShouldPin || (firstVisibleItem < getHeaderViewsCount())) {  
  68.             mCurrentHeader = null;  
  69.             mHeaderOffset = 0.0f;  
  70.             for (int i = firstVisibleItem; i < firstVisibleItem + visibleItemCount; i++) {  
  71.                 View header = getChildAt(i);  
  72.                 if (header != null) {  
  73.                     header.setVisibility(VISIBLE);  
  74.                 }  
  75.             }  
  76.             return;  
  77.         }  
  78.   
  79.         firstVisibleItem -= getHeaderViewsCount();  
  80.   
  81.         int section = mAdapter.getSectionForPosition(firstVisibleItem);  
  82.         int viewType = mAdapter.getSectionHeaderViewType(section);  
  83.         mCurrentHeader = getSectionHeaderView(section, mCurrentHeaderViewType != viewType ? null : mCurrentHeader);  
  84.         ensurePinnedHeaderLayout(mCurrentHeader);  
  85.         mCurrentHeaderViewType = viewType;  
  86.   
  87.         mHeaderOffset = 0.0f;  
  88.   
  89.         for (int i = firstVisibleItem; i < firstVisibleItem + visibleItemCount; i++) {  
  90.             if (mAdapter.isSectionHeader(i)) {  
  91.                 View header = getChildAt(i - firstVisibleItem);  
  92.                 float headerTop = header.getTop();  
  93.                 float pinnedHeaderHeight = mCurrentHeader.getMeasuredHeight();  
  94.                 header.setVisibility(VISIBLE);  
  95.                 if (pinnedHeaderHeight >= headerTop && headerTop > 0) {  
  96.                     mHeaderOffset = headerTop - header.getHeight();  
  97.                 } else if (headerTop <= 0) {  
  98.                     header.setVisibility(INVISIBLE);  
  99.                 }  
  100.             }  
  101.         }  
  102.   
  103.         invalidate();  
  104.     }  
  105.   
  106.     @Override  
  107.     public void onScrollStateChanged(AbsListView view, int scrollState) {  
  108.         if (mOnScrollListener != null) {  
  109.             mOnScrollListener.onScrollStateChanged(view, scrollState);  
  110.         }  
  111.     }  
  112.   
  113.     private View getSectionHeaderView(int section, View oldView) {  
  114.         boolean shouldLayout = section != mCurrentSection || oldView == null;  
  115.   
  116.         View view = mAdapter.getSectionHeaderView(section, oldView, this);  
  117.         if (shouldLayout) {  
  118.             // a new section, thus a new header. We should lay it out again  
  119.             ensurePinnedHeaderLayout(view);  
  120.             mCurrentSection = section;  
  121.         }  
  122.         return view;  
  123.     }  
  124.   
  125.     private void ensurePinnedHeaderLayout(View header) {  
  126.         if (header.isLayoutRequested()) {  
  127.             int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), mWidthMode);  
  128.               
  129.             int heightSpec;  
  130.             ViewGroup.LayoutParams layoutParams = header.getLayoutParams();  
  131.             if (layoutParams != null && layoutParams.height > 0) {  
  132.                 heightSpec = MeasureSpec.makeMeasureSpec(layoutParams.height, MeasureSpec.EXACTLY);  
  133.             } else {  
  134.                 heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);  
  135.             }  
  136.             header.measure(widthSpec, heightSpec);  
  137.             header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());  
  138.         }  
  139.     }  
  140.   
  141.     @Override  
  142.     protected void dispatchDraw(Canvas canvas) {  
  143.         super.dispatchDraw(canvas);  
  144.         if (mAdapter == null || !mShouldPin || mCurrentHeader == null)  
  145.             return;  
  146.         int saveCount = canvas.save();  
  147.         canvas.translate(0, mHeaderOffset);  
  148.         canvas.clipRect(0, 0, getWidth(), mCurrentHeader.getMeasuredHeight()); // needed  
  149.         // for  
  150.         // <  
  151.         // HONEYCOMB  
  152.         mCurrentHeader.draw(canvas);  
  153.         canvas.restoreToCount(saveCount);  
  154.     }  
  155.   
  156.     @Override  
  157.     public void setOnScrollListener(OnScrollListener l) {  
  158.         mOnScrollListener = l;  
  159.     }  
  160.   
  161.     @Override  
  162.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
  163.         super.onMeasure(widthMeasureSpec, heightMeasureSpec);  
  164.   
  165.         mWidthMode = MeasureSpec.getMode(widthMeasureSpec);  
  166.         mHeightMode = MeasureSpec.getMode(heightMeasureSpec);  
  167.     }  
  168.   
  169.     public void setOnItemClickListener(PinnedHeaderListView.OnItemClickListener listener) {  
  170.         super.setOnItemClickListener(listener);  
  171.     }  
  172.   
  173.     public static abstract class OnItemClickListener implements AdapterView.OnItemClickListener {  
  174.         @Override  
  175.         public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {  
  176.             SectionedBaseAdapter adapter;  
  177.             if (adapterView.getAdapter().getClass().equals(HeaderViewListAdapter.class)) {  
  178.                 HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();  
  179.                 adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter();  
  180.             } else {  
  181.                 adapter = (SectionedBaseAdapter) adapterView.getAdapter();  
  182.             }  
  183.             int section = adapter.getSectionForPosition(rawPosition);  
  184.             int position = adapter.getPositionInSectionForPosition(rawPosition);  
  185.   
  186.             if (position == -1) {  
  187.                 onSectionClick(adapterView, view, section, id);  
  188.             } else {  
  189.                 onItemClick(adapterView, view, section, position, id);  
  190.             }  
  191.         }  
  192.   
  193.         public abstract void onItemClick(AdapterView<?> adapterView, View view, int section, int position, long id);  
  194.   
  195.         public abstract void onSectionClick(AdapterView<?> adapterView, View view, int section, long id);  
  196.   
  197.     }  
  198. }  

SectionedBaseAdapter    

  1. import android.util.SparseArray;  
  2. import android.view.View;  
  3. import android.view.ViewGroup;  
  4. import android.widget.BaseAdapter;  
  5. import za.co.immedia.pinnedheaderlistview.PinnedHeaderListView.PinnedSectionedHeaderAdapter;  
  6.   
  7. public abstract class SectionedBaseAdapter extends BaseAdapter implements PinnedSectionedHeaderAdapter {  
  8.     private static int HEADER_VIEW_TYPE = 0;  
  9.     private static int ITEM_VIEW_TYPE = 0;  
  10.   
  11.     /** 
  12.      * Holds the calculated values of @{link getPositionInSectionForPosition} 
  13.      */  
  14.     private SparseArray<Integer> mSectionPositionCache;  
  15.     /** 
  16.      * Holds the calculated values of @{link getSectionForPosition} 
  17.      */  
  18.     private SparseArray<Integer> mSectionCache;  
  19.     /** 
  20.      * Holds the calculated values of @{link getCountForSection} 
  21.      */  
  22.     private SparseArray<Integer> mSectionCountCache;  
  23.   
  24.     /** 
  25.      * Caches the item count 
  26.      */  
  27.     private int mCount;  
  28.     /** 
  29.      * Caches the section count 
  30.      */  
  31.     private int mSectionCount;  
  32.   
  33.     public SectionedBaseAdapter() {  
  34.         super();  
  35.         mSectionCache = new SparseArray<Integer>();  
  36.         mSectionPositionCache = new SparseArray<Integer>();  
  37.         mSectionCountCache = new SparseArray<Integer>();  
  38.         mCount = -1;  
  39.         mSectionCount = -1;  
  40.     }  
  41.   
  42.     @Override  
  43.     public void notifyDataSetChanged() {  
  44.         mSectionCache.clear();  
  45.         mSectionPositionCache.clear();  
  46.         mSectionCountCache.clear();  
  47.         mCount = -1;  
  48.         mSectionCount = -1;  
  49.         super.notifyDataSetChanged();  
  50.     }  
  51.   
  52.     @Override  
  53.     public void notifyDataSetInvalidated() {  
  54.         mSectionCache.clear();  
  55.         mSectionPositionCache.clear();  
  56.         mSectionCountCache.clear();  
  57.         mCount = -1;  
  58.         mSectionCount = -1;  
  59.         super.notifyDataSetInvalidated();  
  60.     }  
  61.   
  62.     @Override  
  63.     public final int getCount() {  
  64.         if (mCount >= 0) {  
  65.             return mCount;  
  66.         }  
  67.         int count = 0;  
  68.         for (int i = 0; i < internalGetSectionCount(); i++) {  
  69.             count += internalGetCountForSection(i);  
  70.             count++; // for the header view  
  71.         }  
  72.         mCount = count;  
  73.         return count;  
  74.     }  
  75.   
  76.     @Override  
  77.     public final Object getItem(int position) {  
  78.         return getItem(getSectionForPosition(position), getPositionInSectionForPosition(position));  
  79.     }  
  80.   
  81.     @Override  
  82.     public final long getItemId(int position) {  
  83.         return getItemId(getSectionForPosition(position), getPositionInSectionForPosition(position));  
  84.     }  
  85.   
  86.     @Override  
  87.     public final View getView(int position, View convertView, ViewGroup parent) {  
  88.         if (isSectionHeader(position)) {  
  89.             return getSectionHeaderView(getSectionForPosition(position), convertView, parent);  
  90.         }  
  91.         return getItemView(getSectionForPosition(position), getPositionInSectionForPosition(position), convertView, parent);  
  92.     }  
  93.   
  94.     @Override  
  95.     public final int getItemViewType(int position) {  
  96.         if (isSectionHeader(position)) {  
  97.             return getItemViewTypeCount() + getSectionHeaderViewType(getSectionForPosition(position));  
  98.         }  
  99.         return getItemViewType(getSectionForPosition(position), getPositionInSectionForPosition(position));  
  100.     }  
  101.   
  102.     @Override  
  103.     public final int getViewTypeCount() {  
  104.         return getItemViewTypeCount() + getSectionHeaderViewTypeCount();  
  105.     }  
  106.   
  107.     public final int getSectionForPosition(int position) {  
  108.         // first try to retrieve values from cache  
  109.         Integer cachedSection = mSectionCache.get(position);  
  110.         if (cachedSection != null) {  
  111.             return cachedSection;  
  112.         }  
  113.         int sectionStart = 0;  
  114.         for (int i = 0; i < internalGetSectionCount(); i++) {  
  115.             int sectionCount = internalGetCountForSection(i);  
  116.             int sectionEnd = sectionStart + sectionCount + 1;  
  117.             if (position >= sectionStart && position < sectionEnd) {  
  118.                 mSectionCache.put(position, i);  
  119.                 return i;  
  120.             }  
  121.             sectionStart = sectionEnd;  
  122.         }  
  123.         return 0;  
  124.     }  
  125.   
  126.     public int getPositionInSectionForPosition(int position) {  
  127.         // first try to retrieve values from cache  
  128.         Integer cachedPosition = mSectionPositionCache.get(position);  
  129.         if (cachedPosition != null) {  
  130.             return cachedPosition;  
  131.         }  
  132.         int sectionStart = 0;  
  133.         for (int i = 0; i < internalGetSectionCount(); i++) {  
  134.             int sectionCount = internalGetCountForSection(i);  
  135.             int sectionEnd = sectionStart + sectionCount + 1;  
  136.             if (position >= sectionStart && position < sectionEnd) {  
  137.                 int positionInSection = position - sectionStart - 1;  
  138.                 mSectionPositionCache.put(position, positionInSection);  
  139.                 return positionInSection;  
  140.             }  
  141.             sectionStart = sectionEnd;  
  142.         }  
  143.         return 0;  
  144.     }  
  145.   
  146.     public final boolean isSectionHeader(int position) {  
  147.         int sectionStart = 0;  
  148.         for (int i = 0; i < internalGetSectionCount(); i++) {  
  149.             if (position == sectionStart) {  
  150.                 return true;  
  151.             } else if (position < sectionStart) {  
  152.                 return false;  
  153.             }  
  154.             sectionStart += internalGetCountForSection(i) + 1;  
  155.         }  
  156.         return false;  
  157.     }  
  158.   
  159.     public int getItemViewType(int section, int position) {  
  160.         return ITEM_VIEW_TYPE;  
  161.     }  
  162.   
  163.     public int getItemViewTypeCount() {  
  164.         return 1;  
  165.     }  
  166.   
  167.     public int getSectionHeaderViewType(int section) {  
  168.         return HEADER_VIEW_TYPE;  
  169.     }  
  170.   
  171.     public int getSectionHeaderViewTypeCount() {  
  172.         return 1;  
  173.     }  
  174.   
  175.     public abstract Object getItem(int section, int position);  
  176.   
  177.     public abstract long getItemId(int section, int position);  
  178.   
  179.     public abstract int getSectionCount();  
  180.   
  181.     public abstract int getCountForSection(int section);  
  182.   
  183.     public abstract View getItemView(int section, int position, View convertView, ViewGroup parent);  
  184.   
  185.     public abstract View getSectionHeaderView(int section, View convertView, ViewGroup parent);  
  186.   
  187.     private int internalGetCountForSection(int section) {  
  188.         Integer cachedSectionCount = mSectionCountCache.get(section);  
  189.         if (cachedSectionCount != null) {  
  190.             return cachedSectionCount;  
  191.         }  
  192.         int sectionCount = getCountForSection(section);  
  193.         mSectionCountCache.put(section, sectionCount);  
  194.         return sectionCount;  
  195.     }  
  196.   
  197.     private int internalGetSectionCount() {  
  198.         if (mSectionCount >= 0) {  
  199.             return mSectionCount;  
  200.         }  
  201.         mSectionCount = getSectionCount();  
  202.         return mSectionCount;  
  203.     }  
  204.   
  205. }  

TestSectionedAdapter  适配器

  1. import java.util.ArrayList;  
  2. import java.util.HashMap;  
  3. import java.util.List;  
  4. import java.util.Map;  
  5.   
  6. import za.co.immedia.pinnedheaderlistview.SectionedBaseAdapter;  
  7. import android.content.Context;  
  8. import android.view.LayoutInflater;  
  9. import android.view.View;  
  10. import android.view.View.OnClickListener;  
  11. import android.view.ViewGroup;  
  12. import android.widget.LinearLayout;  
  13. import android.widget.RelativeLayout;  
  14. import android.widget.TextView;  
  15.   
  16. public class TestSectionedAdapter extends SectionedBaseAdapter{  
  17.     private List<String> titles;//所有标题  
  18.     private Map<String,List<SWWSafearea>> mMap;//根据首字母存放数据  
  19.       
  20.     public TestSectionedAdapter(){  
  21.         List<SWWSafearea> localWifi=new ArrayList<SWWSafearea>();  
  22.         for(int i=1;i<=10;i++){  
  23.             localWifi.add(new SWWSafearea(i,"10"+i));  
  24.         }  
  25.           
  26.         List<SWWSafearea> localGeography=new ArrayList<SWWSafearea>();  
  27.         for(int i=4;i<=15;i++){  
  28.             localGeography.add(new SWWSafearea(i,"10"+i,i));  
  29.         }  
  30.           
  31.         List<SWWSafearea> serverWifi=new ArrayList<SWWSafearea>();  
  32. //      for(int i=7;i<=9;i++){  
  33. //          serverWifi.add(new SWWSafearea(i,"10"+i));  
  34. //      }  
  35.           
  36.         List<SWWSafearea> serverGeography=new ArrayList<SWWSafearea>();  
  37.         for(int i=30;i<=60;i++){  
  38.             serverGeography.add(new SWWSafearea(i,"10"+i,i));  
  39.         }  
  40.           
  41.         titles=new ArrayList<String>();  
  42.         titles.add("1");  
  43.         titles.add("2");  
  44.         titles.add("3");  
  45.         titles.add("4");  
  46.           
  47.         mMap = new HashMap<String, List<SWWSafearea>>();  
  48.         mMap.put(titles.get(0),localWifi);  
  49.         mMap.put(titles.get(1),localGeography);  
  50.         mMap.put(titles.get(2),serverWifi);  
  51.         mMap.put(titles.get(3),serverGeography);  
  52.     }  
  53.   
  54.     @Override  
  55.     public Object getItem(int section, int position) {  
  56.         return mMap.get(titles.get(section)).get(position);  
  57.     }  
  58.   
  59.     @Override  
  60.     public long getItemId(int section, int position) {  
  61.         return 0;  
  62.     }  
  63.   
  64.     @Override  
  65.     public int getSectionCount() {//一共显示多少行标题栏  
  66.         return titles.size();  
  67.     }  
  68.   
  69.     //每列显示的行数  
  70.     @Override  
  71.     public int getCountForSection(int section) {  
  72.         return mMap.get(titles.get(section)).size();  
  73.     }  
  74.   
  75.     @Override  
  76.     public View getItemView(final int section,final int position, View convertView, ViewGroup parent) {  
  77.         ViewHolder holder=null;  
  78.         if (null==convertView) {  
  79.             holder=new ViewHolder();  
  80.             LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
  81.             convertView=(LinearLayout)inflator.inflate(R.layout.list_item, null);  
  82.             holder.name=(TextView) convertView.findViewById(R.id.name);  
  83.             holder.radius=(TextView) convertView.findViewById(R.id.radius);  
  84.             holder.safeareaItem=(RelativeLayout) convertView.findViewById(R.id.safearea_item);  
  85.             convertView.setTag(holder);  
  86.         }else{  
  87.             holder=(ViewHolder) convertView.getTag();  
  88.         }  
  89.         SWWSafearea sf=mMap.get(titles.get(section)).get(position);  
  90.         if(section==0||section==2){  
  91.             holder.name.setText(sf.name);  
  92.             holder.radius.setText("");  
  93.         }else{  
  94.             holder.name.setText(sf.name);  
  95.             holder.radius.setText(""+sf.radius);  
  96.         }  
  97.         holder.safeareaItem.setOnClickListener(new OnClickListener() {  
  98.             @Override  
  99.             public void onClick(View v) {  
  100.                 mMap.get(titles.get(section)).remove(position);  
  101.                 notifyDataSetChanged();  
  102.             }  
  103.         });  
  104.         return convertView;  
  105.     }  
  106.       
  107.     private class ViewHolder{  
  108.         TextView name,radius;  
  109.         RelativeLayout safeareaItem;  
  110.     }  
  111.   
  112.     @Override  
  113.     public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {  
  114.         LinearLayout layout = null;  
  115.         if (convertView == null) {  
  116.             LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
  117.             layout = (LinearLayout) inflator.inflate(R.layout.header_item, null);  
  118.         } else {  
  119.             layout = (LinearLayout) convertView;  
  120.         }  
  121.           
  122.         TextView textView=((TextView) layout.findViewById(R.id.textItem));  
  123.         if(mMap.get(titles.get(section)).size()>0){  
  124.             textView.setVisibility(View.VISIBLE);  
  125.             textView.setText(titles.get(section));  
  126.         }else{  
  127.             textView.setVisibility(View.GONE);  
  128.         }  
  129.         return layout;  
  130.     }  
  131.       
  132.       
  133.   
  134.     //实体类  
  135.     private class SWWSafearea{  
  136.         public int id;  
  137.         public String name;  
  138.         public int radius;  
  139.         public SWWSafearea(int id, String name, int radius) {  
  140.             super();  
  141.             this.id = id;  
  142.             this.name = name;  
  143.             this.radius = radius;  
  144.         }  
  145.           
  146.         public SWWSafearea(int id, String name) {  
  147.             super();  
  148.             this.id = id;  
  149.             this.name = name;  
  150.         }  
  151.     }  
  152. }  

MainActivity  

  1. import android.app.Activity;  
  2. import android.os.Bundle;  
  3. import android.view.Menu;  
  4. import za.co.immedia.pinnedheaderlistview.PinnedHeaderListView;  
  5.   
  6. public class MainActivity extends Activity {  
  7.   
  8.     @Override  
  9.     public void onCreate(Bundle savedInstanceState) {  
  10.         super.onCreate(savedInstanceState);  
  11.         setContentView(R.layout.activity_main);  
  12.         PinnedHeaderListView listView = (PinnedHeaderListView) findViewById(R.id.pinnedListView);  
  13.           
  14.         TestSectionedAdapter sectionedAdapter = new TestSectionedAdapter();  
  15.         listView.setAdapter(sectionedAdapter);  
  16.     }  
  17.   
  18.     @Override  
  19.     public boolean onCreateOptionsMenu(Menu menu) {  
  20.         getMenuInflater().inflate(R.menu.activity_main, menu);  
  21.         return true;  
  22.     }  
  23. }  

效果图如下:

推荐下自己创建的android QQ群:202928390   欢迎大家的加入.

时间: 2024-09-01 04:50:11

PinnedHeaderListView实现删除的相关文章

Android SwipeActionAdapter结合Pinnedheaderlistview实现复杂列表的左右滑动操作

  在上一篇博客<Android 使用SwipeActionAdapter开源库实现简单列表的左右滑动操作>里,已经介绍了利用SwipeActionAdapter来左右滑动操作列表: 然,有时候,会要求一些特殊的列表也能够实现左右滑动: 列表滑动过程中,分组标题可以固定在顶部,同时列表支持左右滑动!效果图如下:   那么该如何实现呢,一开始,我是打算使用SwipeActionAdapter+StickyListView 来做,尝试一番后,发现左右滑动ListView Item时,它的背景(上图

删除IE8浏览历史记录后地址栏仍显示

为什么在IE8浏览器中删除浏览历史记录后,怎么在地址栏的下拉菜单还有一大堆自动完成建议.历史记录.收藏夹等信息. 这是因为IE8采用 Windows Search 对已经访问过的内容进行索引,当您向地址栏输入地址时,IE8会自动从索引中搜索.提取信息(Windows XP 需另外下载安装 Windows Search 才能实现此功能).这本是IE8的便利之处,但是有时候好像成为大家的不便之处. 解决方法: 如果不需要,我们可以禁用 IE浏览器 和 Windows Search 的整合.具体操作如

jquery删除提示框弹出是否删除对话框

 想必大家对删除提示框并不陌生吧,也就是大家常见的弹出是否删除的对话框,下面使用jquery来实现下,感兴趣的朋友不要错过  代码如下: /**  * 删除草稿  */  function deleteDraft(the,id){  $.messager.confirm('删除草稿提醒', '</br>确定删除这篇草稿吗?</br></br>',function(r){  if(r){  $.ajax({  type : "post",  url :

php遍历删除整个目录及文件的方法

 这篇文章主要介绍了php遍历删除整个目录及文件的方法,涉及php操作目录及文件的技巧,具有一定参考借鉴价值,需要的朋友可以参考下     本文实例讲述了php遍历删除整个目录及文件的方法.分享给大家供大家参考.具体分析如下: 我们可以使用RecursiveDirectoryIterator 和 RecursiveIteratorIterator删除目录和子目录及文件,子目录将先与父目录删除 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <?php function

php中通过DirectoryIterator删除整个目录的方法

这篇文章主要介绍了php中通过DirectoryIterator删除整个目录的方法,实例分析了php通过DirectoryIterator类操作目录的技巧,具有一定参考借鉴价值,需要的朋友可以参考下     本文实例讲述了php中通过DirectoryIterator删除整个目录的方法.分享给大家供大家参考.具体实现方法如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <?php function cleanup_directory($dir) { foreach (

php操作(删除,提取,增加)zip文件方法详解

 本文给大家分享的是php操作zip文件的方法示例,包括了从zip压缩文件中提取文件.从一个zip压缩文件中删除文件.添加一个文件到zip压缩文件中,推荐给大家,有需要的小伙伴参考下.     php读取zip文件(删除文件,提取文件,增加文件)实例 从zip压缩文件中提取文件   代码如下: <?php /* php 从zip压缩文件中提取文件 */ $zip = new ZipArchive; if ($zip->open('jQuery五屏上下滚动焦点图代码.zip') === TRUE

win7 64位旗舰版地址栏中网址删除方法

  我们在使用计算机进行一些网址输入和访问的时候,历史记录无疑就不知布局记录在浏览器的地址栏中了,这在一定程度上也给我们的个人信息造成了巨大的影响,因此我们就需要简单的找到如何删除地址栏中的网址的办法,至于如何删除地址栏中的网址就需要我们好好的探究一番了,下面我们在win7 64位旗舰版使用过程中做一个简单的示范操作. 1.在win7中打开ie浏览器中的"Internet选项". 2.接着我们找到页面上的"内容"标签并且执行"自动完成"操作. 3

win7删除桌面文件需要刷新解决

  有没有遇到过这种情况,删除桌面文件没有效果,要点右键的刷新删除过的文件才会在桌面上消失!解决方法有两种: 第一种方法 点击"开始→运行",在对话框中输入"regedit"启动注册表编辑器,展开HKEY_LOCAL_MACHINESystemCurrentControlSetControlUpdate分支.在右面找到一个名为"UpdateMode"的DWORD值,用鼠标双击"UpdateMode"在出现的窗口中将其值修改为&

360云盘如何找回已删除文件

  360云盘找回已删除文件方法:在云盘客户端.网页版等处进行的删除操作,360云盘都将暂时将这些文件删除到云盘回收站里.这样如果用户进行了某些误操作,想找回文件,就可以去云盘网页版回收站找回这些文件.