你好,游客 登录 注册 搜索
背景:
阅读新闻

Android开发教程:OnScrollListener实现ListActivity滚屏首字母提示

[日期:2012-02-20] 来源:Linux社区  作者:ace1985 [字体:大 中 小]

OnScrollListener接口是定义在AbsListView中的,而AbsListView的直接子类有GridView和ListView,非直接子类有ExpandableListView。OnScrollListener的完整路径是frameworks\base\core\java\Android\widget\AbsListView.java,代码如下:

[java]
  1. /** 
  2.  * Interface definition for a callback to be invoked when the list or grid 
  3.  * has been scrolled. 
  4.  */  
  5. public interface OnScrollListener {  
  6.   
  7.     /** 
  8.      * The view is not scrolling. Note navigating the list using the trackball counts as 
  9.      * being in the idle state since these transitions are not animated. 
  10.      */  
  11.     public static int SCROLL_STATE_IDLE = 0;  
  12.   
  13.     /** 
  14.      * The user is scrolling using touch, and their finger is still on the screen 
  15.      */  
  16.     public static int SCROLL_STATE_TOUCH_SCROLL = 1;  
  17.   
  18.     /** 
  19.      * The user had previously been scrolling using touch and had performed a fling. The 
  20.      * animation is now coasting to a stop 
  21.      */  
  22.     public static int SCROLL_STATE_FLING = 2;  
  23.   
  24.     /** 
  25.      * Callback method to be invoked while the list view or grid view is being scrolled. If the 
  26.      * view is being scrolled, this method will be called before the next frame of the scroll is 
  27.      * rendered. In particular, it will be called before any calls to 
  28.      * {@link Adapter#getView(int, View, ViewGroup)}. 
  29.      * 
  30.      * @param view The view whose scroll state is being reported 
  31.      * 
  32.      * @param scrollState The current scroll state. One of {@link #SCROLL_STATE_IDLE}, 
  33.      * {@link #SCROLL_STATE_TOUCH_SCROLL} or {@link #SCROLL_STATE_IDLE}. 
  34.      */  
  35.     public void onScrollStateChanged(AbsListView view, int scrollState);  
  36.   
  37.     /** 
  38.      * Callback method to be invoked when the list or grid has been scrolled. This will be 
  39.      * called after the scroll has completed 
  40.      * @param view The view whose scroll state is being reported 
  41.      * @param firstVisibleItem the index of the first visible cell (ignore if 
  42.      *        visibleItemCount == 0) 
  43.      * @param visibleItemCount the number of visible cells 
  44.      * @param totalItemCount the number of items in the list adaptor 
  45.      */  
  46.     public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,  
  47.             int totalItemCount);  
  48. }  
linux
相关资讯       Android开发教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款