@Override protected void onFinishInflate() { mHandle = findViewById(R.id.drawer_handle); mListView = (TestListView) findViewById(R.id.drawer_list_view); mListView.setDividerHeight(0); mListView.setItemsCanFocus(true); mAdapter = new TestAdapter(mActivity); mListView.setAdapter(mAdapter); // Must be called after mAdapter.setListView(), // disable the list view to response the click event, // but let the item response by its own. mListView.setOnItemClickListener(null); mListView.setOnScrollListener( new OnScrollListener() { @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem == 0) { View firstVisibleItemView = mListView.getChildAt(0); if (firstVisibleItemView != null && firstVisibleItemView.getTop() == 0) { Log.d("ListView", "##### 滚动到顶部 #####"); mIsListViewScrollOnTop = true; return; } } else if ((firstVisibleItem + visibleItemCount) == totalItemCount) { View lastVisibleItemView = mListView.getChildAt(mListView.getChildCount() - 1); if (lastVisibleItemView != null && lastVisibleItemView.getBottom() == mListView.getHeight()) { Log.d("ListView", "##### 滚动到底部 ######"); } } mIsListViewScrollOnTop = false; } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { // do nothing } }); // must be called at the end. super.onFinishInflate(); updateHandleBackground(1.0f); }
/** Called each time before start to animating/tracking */ @Override protected void prepareContent() { super.prepareContent(); }