List of usage examples for android.widget ListView setOnScrollListener
public void setOnScrollListener(OnScrollListener l)
From source file:com.android.tabcarouseldemo.DummyListFragment.java
/** * {@inheritDoc}//ww w .j av a 2 s . co m */ @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ListView listView = getListView(); // Attach the BackScrollManager listView.setOnScrollListener(new BackScrollManager(mCarousel, null, CarouselContainer.TAB_INDEX_FIRST)); // Register the onItemClickListener listView.setOnItemClickListener(this); // We disable the scroll bar because it would otherwise be incorrect // because of the hidden // header listView.setVerticalScrollBarEnabled(false); }
From source file:com.lvfq.rabbit.swipe.DanceFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ListView listView = getListView(); listView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), false, true, new AbsListView.OnScrollListener() { @Override// w w w. ja va2 s . co m public void onScrollStateChanged(AbsListView arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //Log.d(TAG, "first:"+firstVisibleItem+" visible:"+visibleItemCount+" total:"+totalItemCount+" last:"+listView.getLastVisiblePosition()); if (isNetworkConnected() && listView.getLastVisiblePosition() >= 0 && listView.getLastVisiblePosition() == listView.getAdapter().getCount() - 1 && listView.getChildAt(listView.getChildCount() - 1).getBottom() <= listView .getHeight()) { synchronized (canLoadMore) { Log.d(TAG, "load more"); canLoadMore = false; new DanceLoadMoreBackgroundTask().execute(); } } } })); if (rabbitAdapter.orderListRabbitData == null) initiateRefresh(); }
From source file:com.lvfq.rabbit.swipe.NewsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ListView listView = getListView(); listView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), false, true, new AbsListView.OnScrollListener() { @Override/*from w w w . j a va 2 s. c o m*/ public void onScrollStateChanged(AbsListView arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //Log.d(TAG, "first:"+firstVisibleItem+" visible:"+visibleItemCount+" total:"+totalItemCount+" last:"+listView.getLastVisiblePosition()); if (isNetworkConnected() && listView.getLastVisiblePosition() >= 0 && listView.getLastVisiblePosition() == listView.getAdapter().getCount() - 1 && listView.getChildAt(listView.getChildCount() - 1).getBottom() <= listView .getHeight()) { synchronized (canLoadMore) { Log.d(TAG, "load more"); canLoadMore = false; new NewsLoadMoreBackgroundTask().execute(); } } } })); if (rabbitAdapter.orderListRabbitData == null) initiateRefresh(); }
From source file:org.mariotaku.twidere.fragment.support.BaseSupportListFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mNotReachedBottomBefore = true;/*from ww w . j a v a 2s .c o m*/ mIsInstanceStateSaved = savedInstanceState != null; final ListView lv = getListView(); lv.setOnScrollListener(this); }
From source file:org.bwgz.quotation.activity.SearchResultsActivity.java
private void handleIntent(final Intent intent) { Log.d(TAG, String.format("handleIntent - intent: %s", intent)); String query = intent.getStringExtra(SearchManager.QUERY); int type = intent.getIntExtra(SearchResultsActivity.EXTRA_SEARCH_TYPE, FreebaseSearch.SEARCH_TYPE_KEYWORD); getTracker().send(MapBuilder.createEvent("ui.search", getSearchType(type), query, null).build()); searchResultsAdapter = new SearchResultsAdapter(this, R.layout.quotation_pick_view, new ArrayList<Pick>(), this, getImageLoader()); loadSearchResultsTask = (SearchResultsTask) new SearchResultsTask(this, searchResultsAdapter, 0, DEFAULT_LIMIT).execute(intent); ListView listView = (ListView) findViewById(R.id.result_list); listView.setAdapter(searchResultsAdapter); listView.setOnScrollListener(new OnScrollListener() { @Override/*from w w w .java2 s. c o m*/ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { Log.d(TAG, String.format( "onScroll - view %s firstVisibleItem: %d visibleItemCount: %d totalItemCount: %d", view, firstVisibleItem, visibleItemCount, totalItemCount)); if ((loadSearchResultsTask.getStatus() == AsyncTask.Status.FINISHED) && (totalItemCount < searchResultsAdapter.getHits()) && (firstVisibleItem + visibleItemCount == totalItemCount)) { Log.d(TAG, "Load Next Page!"); loadSearchResultsTask = (SearchResultsTask) new SearchResultsTask(SearchResultsActivity.this, searchResultsAdapter, totalItemCount, Math.max(visibleItemCount, DEFAULT_LIMIT)) .execute(intent); } } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } }); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { SearchResultsAdapter adapter = (SearchResultsAdapter) parent.getAdapter(); List<String> mids = new ArrayList<String>(); for (int i = 0; i < adapter.getCount(); i++) { Pick pick = (Pick) adapter.getItem(i); mids.add(pick.getId()); } Intent intent = new Intent(getApplicationContext(), QuotationActivity.class); intent.putExtra(QuotationActivity.EXTRA_IDS, mids.toArray(new String[mids.size()])); intent.putExtra(QuotationActivity.EXTRA_POSITION, position); startActivity(intent); } }); }
From source file:at.ac.uniklu.mobile.sportal.CalendarFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.calendar_fragment, container, false); mProgressView = v.findViewById(R.id.progress); mFooterView = inflater.inflate(R.layout.list_footer_loadingindicator, null); ListView listView = (ListView) v.findViewById(android.R.id.list); listView.addFooterView(mFooterView, null, false); listView.setOnScrollListener(this); /* change reference to inner progress indicator since hiding the footer * container itself doesn't resize the layout (black box stays visible) */ mFooterView = mFooterView.findViewById(R.id.list_progress); return v;//w ww . j av a2 s.c o m }
From source file:de.vanita5.twittnuker.fragment.support.BaseSupportListFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mNotReachedBottomBefore = true;//from w w w . j a v a 2 s .c o m mStoppedPreviously = false; mIsInstanceStateSaved = savedInstanceState != null; final ListView lv = getListView(); lv.setOnScrollListener(this); }
From source file:com.ekuater.labelchat.ui.fragment.userInfo.HeaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Activity activity = getActivity(); assert activity != null; mFrameLayout = new FrameLayout(activity); mCover = onCoverView(inflater, mFrameLayout); mHeader = onCreateHeaderView(inflater, mFrameLayout); mHeaderHeader = mHeader.findViewById(android.R.id.title); mHeaderBackground = mHeader.findViewById(android.R.id.background); assert mHeader.getLayoutParams() != null; mHeaderHeight = mHeader.getLayoutParams().height; mFakeHeader = new Space(activity); mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight)); View content = onCreateContentView(inflater, mFrameLayout); if (content instanceof RelativeLayout) { isListViewEmpty = true;//www . ja va2s . c o m final ListView listView = (ListView) content.findViewById(R.id.list); listView.addHeaderView(mFakeHeader); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { if (mOnScrollListener != null) { mOnScrollListener.onScrollStateChanged(absListView, scrollState); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mOnScrollListener != null) { mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount); } if (isListViewEmpty) { scrollHeaderTo(0); } else { final View child = absListView.getChildAt(0); assert child != null; scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight); } } }); } else { // Merge fake header view and content view. final LinearLayout view = new LinearLayout(activity); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setOrientation(LinearLayout.VERTICAL); view.addView(mFakeHeader); view.addView(content); // Put merged content to ScrollView final NotifyingScrollView scrollView = new NotifyingScrollView(activity); scrollView.addView(view); scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() { @Override public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { scrollHeaderTo(-t); } }); content = scrollView; } mFrameLayout.addView(content); mFrameLayout.addView(mHeader); if (mCover != null) { mFrameLayout.addView(mCover); } // Post initial scroll mFrameLayout.post(new Runnable() { @Override public void run() { scrollHeaderTo(0, true); } }); return mFrameLayout; }
From source file:vit.collegecode.mediadb.fragments.HeaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Activity activity = getActivity(); assert activity != null; mFrameLayout = new FrameLayout(activity); mHeader = onCreateHeaderView(inflater, mFrameLayout); mHeaderHeader = mHeader.findViewById(android.R.id.title); mHeaderBackground = mHeader.findViewById(android.R.id.background); assert mHeader.getLayoutParams() != null; mHeaderHeight = mHeader.getLayoutParams().height; mFakeHeader = new Space(activity); mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight)); View content = onCreateContentView(inflater, mFrameLayout); if (content instanceof ListView) { isListViewEmpty = true;//from www . j av a 2 s . c o m final ListView listView = (ListView) content; listView.addHeaderView(mFakeHeader); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { if (mOnScrollListener != null) { mOnScrollListener.onScrollStateChanged(absListView, scrollState); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (isListViewEmpty) { scrollHeaderTo(0); } else { final View child = absListView.getChildAt(0); assert child != null; scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight); } } }); } else { // Merge fake header view and content view. final LinearLayout view = new LinearLayout(activity); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setOrientation(LinearLayout.VERTICAL); view.addView(mFakeHeader); view.addView(content); // Put merged content to ScrollView final NotifyingScrollView scrollView = new NotifyingScrollView(activity); scrollView.addView(view); scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() { @Override public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { scrollHeaderTo(-t); } }); content = scrollView; } mFrameLayout.addView(content); mFrameLayout.addView(mHeader); // Content overlay view always shows at the top of content. if ((mContentOverlay = onCreateContentOverlayView(inflater, mFrameLayout)) != null) { mFrameLayout.addView(mContentOverlay, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } // Post initial scroll mFrameLayout.post(new Runnable() { @Override public void run() { scrollHeaderTo(0, true); } }); Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_bottom); mFrameLayout.startAnimation(anim); return mFrameLayout; }
From source file:org.anurag.fragments.AppStore.java
/** * this function sets transition effect for list view.... * @param list2//from www .j ava 2 s . c o m */ private void setAnim(ListView list2) { // TODO Auto-generated method stub //JazzyHelper help = new JazzyHelper(getActivity(), null); list_anim_helper.setTransitionEffect(Constants.LIST_ANIM); list2.setOnScrollListener(list_anim_helper); }