Java Code Examples for android.widget.listview#setOnScrollListener()
The following examples show how to use
android.widget.listview#setOnScrollListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FadingActionBarHelperBase.java From ALLGO with Apache License 2.0 | 6 votes |
private View createListView(ListView listView) { mContentContainer = (ViewGroup) mInflater.inflate(R.layout.fab__listview_container, null); mContentContainer.addView(mContentView); mHeaderContainer = (FrameLayout) mContentContainer.findViewById(R.id.fab__header_container); initializeGradient(mHeaderContainer); mHeaderContainer.addView(mHeaderView, 0); mMarginView = new FrameLayout(listView.getContext()); mMarginView.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, 0)); listView.addHeaderView(mMarginView, null, false); // Make the background as high as the screen so that it fills regardless of the amount of scroll. mListViewBackgroundView = mContentContainer.findViewById(R.id.fab__listview_background); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mListViewBackgroundView.getLayoutParams(); params.height = Utils.getDisplayHeight(listView.getContext()); mListViewBackgroundView.setLayoutParams(params); listView.setOnScrollListener(mOnScrollListener); return mContentContainer; }
Example 2
Source File: MyStatusesActivity.java From YiBo with Apache License 2.0 | 6 votes |
private void bindEvent() { Button btnBack = (Button)this.findViewById(R.id.btnBack); btnBack.setOnClickListener(new GoBackClickListener()); Button btnOperate = (Button) this.findViewById(R.id.btnOperate); btnOperate.setVisibility(View.VISIBLE); btnOperate.setText(R.string.btn_home); btnOperate.setOnClickListener(new GoHomeClickListener()); ListView lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog); lvMicroBlog.setOnItemClickListener(new MicroBlogItemClickListener(this)); MicroBlogContextMenuListener contextMenuListener = new MicroBlogContextMenuListener(lvMicroBlog); lvMicroBlog.setOnCreateContextMenuListener(contextMenuListener); lvMicroBlog.setOnScrollListener(new StatusScrollListener()); }
Example 3
Source File: ContactFragment.java From sctalk with Apache License 2.0 | 6 votes |
/** * @Description 初始化界面资源 */ private void initRes() { // 设置顶部标题栏 showContactTopBar(); hideTopBar(); super.init(curView); showProgressBar(); sortSideBar = (SortSideBar) curView.findViewById(R.id.sidrbar); dialog = (TextView) curView.findViewById(R.id.dialog); sortSideBar.setTextView(dialog); sortSideBar.setOnTouchingLetterChangedListener(this); allContactListView = (ListView) curView.findViewById(R.id.all_contact_list); departmentContactListView = (ListView) curView.findViewById(R.id.department_contact_list); //this is critical, disable loading when finger sliding, otherwise you'll find sliding is not very smooth allContactListView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), true, true)); departmentContactListView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), true, true)); // todo eric // showLoadingProgressBar(true); }
Example 4
Source File: PullToRefreshList.java From KJFrameForAndroid with Apache License 2.0 | 5 votes |
@Override protected ListView createRefreshView(Context context, AttributeSet attrs) { ListView listView = new ListView(context); mfakeListView = listView; listView.setOnScrollListener(this); return listView; }
Example 5
Source File: ThreadListFragment.java From something.apk with MIT License | 5 votes |
@Override public void viewCreated(View frag, Bundle savedInstanceState) { threadList = (ListView) frag.findViewById(R.id.listview); threadList.setAdapter(adapter); threadList.setOnItemClickListener(adapter); threadList.setOnScrollListener(adapter); threadList.setOnItemLongClickListener(this); }
Example 6
Source File: AudioAlbumsSongsFragment.java From VCL-Android with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.audio_albums_songs, container, false); ListView albumsList = (ListView) v.findViewById(R.id.albums); ListView songsList = (ListView) v.findViewById(R.id.songs); List<View> lists = Arrays.asList((View)albumsList, songsList); String[] titles = new String[] {getString(R.string.albums), getString(R.string.songs)}; mViewPager = (ViewPager) v.findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(MODE_TOTAL - 1); mViewPager.setAdapter(new AudioPagerAdapter(lists, titles)); mViewPager.setOnTouchListener(mSwipeFilter); TabLayout mTabLayout = (TabLayout) v.findViewById(R.id.sliding_tabs); mTabLayout.setupWithViewPager(mViewPager); songsList.setAdapter(mSongsAdapter); albumsList.setAdapter(mAlbumsAdapter); songsList.setOnItemClickListener(songsListener); albumsList.setOnItemClickListener(albumsListener); registerForContextMenu(albumsList); registerForContextMenu(songsList); mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout); mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700); mSwipeRefreshLayout.setOnRefreshListener(this); songsList.setOnScrollListener(mScrollListener); albumsList.setOnScrollListener(mScrollListener); getActivity().setTitle(mTitle); return v; }
Example 7
Source File: AbstractUserListFragment.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.abs_userlist_listview_layout, container, false); // mToolbar = (Toolbar) view.findViewById(R.id.baseToolBar); empty = (TextView) view.findViewById(R.id.empty); mSwipeRefreshLayout = ViewUtility.findViewById(view, R.id.userListSRL); mSwipeRefreshLayout.setOnlyPullRefersh(); mSwipeRefreshLayout.setEnableSount(SettingUtils.getEnableSound()); pullToRefreshListView = (ListView) view.findViewById(R.id.listView); // mSwipeRefreshLayout.setOnRefreshListener(userOnRefreshListener); mSwipeRefreshLayout.setOnRefreshLoadMoreListener(userOnRefreshListener); // pullToRefreshListView.setOnLastItemVisibleListener(new UserListOnLastItemVisibleListener()); // pullToRefreshListView.setOnPullEventListener(getPullEventListener()); pullToRefreshListView.setOnScrollListener(new UserListOnScrollListener()); pullToRefreshListView.setOnItemClickListener(new UserListOnItemClickListener()); pullToRefreshListView.setFooterDividersEnabled(false); dismissFooterView(); userListAdapter = new UserListAdapter(AbstractUserListFragment.this, bean.getUsers(), getListView()); pullToRefreshListView.setAdapter(userListAdapter); return view; }
Example 8
Source File: InfiniteScrollUtils.java From edx-app-android with Apache License 2.0 | 5 votes |
public static <T> InfiniteListController configureListViewWithInfiniteList(@NonNull final ListView list, @NonNull final ArrayAdapter<T> adapter, @NonNull final PageLoader<T> pageLoader) { final PageLoadController controller = new PageLoadController<>( configureListContentController(list, adapter), pageLoader); controller.loadMore(); list.setOnScrollListener(new ListViewOnScrollListener(new Runnable() { @Override public void run() { controller.loadMore(); } })); return controller; }
Example 9
Source File: RefreshLayout.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
/** * 获取ListView对象 */ private void getListView() { int childs = getChildCount(); if (childs > 0) { View childView = getChildAt(0); if (childView instanceof ListView) { mListView = (ListView) childView; // 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载 mListView.setOnScrollListener(this); Log.d(VIEW_LOG_TAG, "### 找到listview"); } } }
Example 10
Source File: AbstractUserListFragment.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.abs_userlist_listview_layout, container, false); // mToolbar = (Toolbar) view.findViewById(R.id.baseToolBar); empty = (TextView) view.findViewById(R.id.empty); mSwipeRefreshLayout = ViewUtility.findViewById(view, R.id.userListSRL); mSwipeRefreshLayout.setOnlyPullRefersh(); mSwipeRefreshLayout.setEnableSount(SettingUtils.getEnableSound()); pullToRefreshListView = (ListView) view.findViewById(R.id.listView); // mSwipeRefreshLayout.setOnRefreshListener(userOnRefreshListener); mSwipeRefreshLayout.setOnRefreshLoadMoreListener(userOnRefreshListener); // pullToRefreshListView.setOnLastItemVisibleListener(new UserListOnLastItemVisibleListener()); // pullToRefreshListView.setOnPullEventListener(getPullEventListener()); pullToRefreshListView.setOnScrollListener(new UserListOnScrollListener()); pullToRefreshListView.setOnItemClickListener(new UserListOnItemClickListener()); pullToRefreshListView.setFooterDividersEnabled(false); dismissFooterView(); userListAdapter = new UserListAdapter(AbstractUserListFragment.this, bean.getUsers(), getListView()); pullToRefreshListView.setAdapter(userListAdapter); return view; }
Example 11
Source File: RefreshLayout.java From Gank with Apache License 2.0 | 5 votes |
/** * 获取ListView对象 */ private void getListView() { int childs = getChildCount(); if (childs > 0) { View childView = getChildAt(0); if (childView instanceof ListView) { mListView = (ListView) childView; // 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载 mListView.setOnScrollListener(this); Log.d(VIEW_LOG_TAG, "### 找到listview"); } } }
Example 12
Source File: TopicsListFragment.java From android-discourse with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ListView listView = getListView(); if (!Utils.isTablet(getActivity())) { // TODO ... // view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color)); } if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) { int verticalMargin = getResources().getDimensionPixelSize(R.dimen.topics_list_padding_vertical); if (verticalMargin > 0) { listView.setClipToPadding(false); listView.setPadding(0, verticalMargin, 0, verticalMargin); } } listView.setOnScrollListener(this); listView.setDrawSelectorOnTop(true); // listView.setDivider(getResources().getDrawable(android.R.color.transparent)); // listView.setDividerHeight(getResources() // .getDimensionPixelSize(R.dimen.page_margin_width)); TypedValue v = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true); listView.setSelector(v.resourceId); setListAdapter(mAdapter); }
Example 13
Source File: CommentListActivity.java From Broadsheet.ie-Android with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_comment_list); if (savedInstanceState != null) { Log.d(TAG, "saved instance"); mPost = (Post) savedInstanceState.getSerializable(CURRENT_POST); } else { Bundle extras = getIntent().getExtras(); if (extras != null) { BroadsheetApplication app = (BroadsheetApplication) getApplication(); if (app.getPosts().size() > 0) { mPost = app.getPosts().get(extras.getInt("item_id")); } } } ListView list = (ListView) findViewById(android.R.id.list); comments = new CommentAdapter(this, R.layout.comment_list_item, mPost.getSortedComments()); comments.setReplyCommentListener(this); list.setAdapter(comments); getSupportActionBar().setDisplayHomeAsUpEnabled(true); boolean pauseOnScroll = false; boolean pauseOnFling = true; PauseOnScrollListener listener = new PauseOnScrollListener(ImageLoader.getInstance(), pauseOnScroll, pauseOnFling); list.setOnScrollListener(listener); setTitle(getResources().getString(R.string.comment)); }
Example 14
Source File: StatusSubscribeActivity.java From YiBo with Apache License 2.0 | 5 votes |
private void initComponents() { LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase); lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog); ThemeUtil.setSecondaryHeader(llHeaderBase); ThemeUtil.setContentBackground(lvMicroBlog); ThemeUtil.setListViewStyle(lvMicroBlog); int temp = getIntent().getIntExtra("STATUS_CATALOG", StatusCatalog.News.getCatalogNo()); catalog = StatusCatalog.getStatusCatalog(temp); if (catalog == null) { return; } int titleId = getIntent().getIntExtra("TITLE_ID", R.string.label_app_daily); TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle); tvTitle.setText(titleId); adapter = new StatusSubscribeListAdapter(this, sheJiaoMao.getCurrentAccount()); showMoreFooter(); lvMicroBlog.setAdapter(adapter); lvMicroBlog.setFastScrollEnabled(sheJiaoMao.isSliderEnabled()); lvMicroBlog.setOnScrollListener(new StatusScrollListener()); setBack2Top(lvMicroBlog); recyclerListener = new StatusRecyclerListener(); lvMicroBlog.setRecyclerListener(recyclerListener); }
Example 15
Source File: UserActionsFragment.java From android-discourse with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ListView listView = getListView(); // TODO fix this // if (!UIUtils.isTablet(getActivity())) { // view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color)); // } // if (getArguments() != null // && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) { // int verticalMargin = getResources().getDimensionPixelSize( // R.dimen.plus_stream_padding_vertical); // if (verticalMargin > 0) { // listView.setClipToPadding(false); // listView.setPadding(0, verticalMargin, 0, verticalMargin); // } // } listView.setOnScrollListener(this); listView.setDrawSelectorOnTop(true); // listView.setDivider(getResources().getDrawable(android.R.color.darker_gray)); // listView.setDividerHeight(getResources() // .getDimensionPixelSize(R.dimen.divider_height)); TypedValue v = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.clickableItemBackground, v, true); listView.setSelector(v.resourceId); setListAdapter(mAdapter); }
Example 16
Source File: Act_NetworkListView.java From android_volley_examples with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.act__network_list_view); mLvPicasa = (ListView) findViewById(R.id.lv_picasa); mAdapter = new PicasaArrayAdapter(this, 0, mEntries, MyVolley.getImageLoader()); mLvPicasa.setAdapter(mAdapter); mLvPicasa.setOnScrollListener(new EndlessScrollListener()); }
Example 17
Source File: MainActivity.java From Android-Audio-Recorder with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setAppTheme(getAppTheme()); setContentView(R.layout.activity_main); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); storage = new Storage(this); handler = new Handler(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (Build.VERSION.SDK_INT >= 16) toolbar.setBackground(new ColorDrawable(MainApplication.getActionbarColor(this))); else toolbar.setBackgroundDrawable(new ColorDrawable(MainApplication.getActionbarColor(this))); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { recordings.select(-1); RecordingActivity.startActivity(MainActivity.this, false); // Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) // .setAction("Action", null).show(); } }); recordings = new Recordings(this); list = (ListView) findViewById(R.id.list); list.setOnScrollListener(this); list.setAdapter(recordings); list.setEmptyView(findViewById(R.id.empty_list)); if (permitted()) { storage.migrateLocalStorage(); } }
Example 18
Source File: IndexableStickyListView.java From SprintNBA with Apache License 2.0 | 4 votes |
private void init(Context context, AttributeSet attrs) { mContext = context; if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IndexableStickyListView); mBarTextColor = a.getColor(R.styleable.IndexableStickyListView_indexBar_textColor, getResources().getColor(R.color.default_indexBar_textcolor)); mBarTextSize = a.getDimension(R.styleable.IndexableStickyListView_indexBar_textSize, getResources().getDimension(R.dimen.default_indexBar_textSize)); mBarSelectedTextColor = a.getColor(R.styleable.IndexableStickyListView_indexBar_selected_textColor, getResources().getColor(R.color.dafault_indexBar_selected_textColor)); mRightOverlayColor = a.getColor(R.styleable.IndexableStickyListView_indexListView_rightOverlayColor, getResources().getColor(R.color.default_indexListView_rightOverlayColor)); mTypeOverlay = a.getInt(R.styleable.IndexableStickyListView_indexListView_type_overlay, 0); a.recycle(); } if (mContext instanceof Activity) { ((Activity) mContext).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } mListView = new ListView(context); mListView.setVerticalScrollBarEnabled(false); mListView.setOverScrollMode(View.OVER_SCROLL_NEVER); mListView.setDivider(null); addView(mListView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mIndexBar = new IndexBar(context, mBarTextColor, mBarSelectedTextColor, mBarTextSize); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); params.gravity = Gravity.RIGHT; params.topMargin = IndexBar.dp2px(context, 16); params.bottomMargin = params.topMargin; addView(mIndexBar, params); if (mTypeOverlay == 1) { showCenterOverlayView(true); } else if (mTypeOverlay == 2) { showRightOverlayView(true, mRightOverlayColor); } mSearchLayout = new SearchLayout(context); LayoutParams paramsLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); addView(mSearchLayout, paramsLayout); mSearchLayout.setVisibility(GONE); mListView.setOnItemClickListener(this); mListView.setOnScrollListener(this); mIndexBar.setOnIndexSelectedListener(new IndexBar.OnIndexTitleSelectedListener() { @Override public void onSelection(int position, String indexTitle) { if (mStickView != null) { if (!mStickView.getText().toString().equals(indexTitle)) { mStickView.setText(indexTitle); } if (mStickView.getY() != 0) { mStickView.setY(0); } } } }); }
Example 19
Source File: HomeFragment.java From QuickNews with MIT License | 4 votes |
public JsonObjectRequest getNewsData(String baseUrl, String parameter, final ListView listView, final SwipeRefreshLayout refreshLayout) { System.out.println("访问的Url为" + (baseUrl + parameter)); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest((baseUrl + parameter).trim(), null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { // System.out.println("Volley得到的response是+" + response.toString()); Gson gson = new Gson(); data = gson.fromJson(response.toString(), new TypeToken<Data>() { }.getType()); List<News> newsList; newsList = data.getData(); refreshLayout.setRefreshing(false); System.out.println("newsList的size是" + newsList.size()); mNewsAdapter = new NewsAdapter(getActivity(), newsList); listView.setAdapter(mNewsAdapter); mNewsAdapter.notifyDataSetChanged(); final List<News> finalNewsList = newsList; listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Intent intent = new Intent(getActivity(), NewsActivity.class); System.out.println("i的位置" + i); System.out.println("newsList的size" + finalNewsList.size()); System.out.println("newsList.get(i).getDisplay_url()" + finalNewsList.get(i).getDisplay_url()); System.out.println("newsList.get(i).getArticle_url()" + finalNewsList.get(i).getArticle_url()); // intent.putExtra("news_url", finalNewsList.get(i).getDisplay_url()); intent.putExtra("news_url", finalNewsList.get(i).getArticle_url()); startActivity(intent); } }); listView.setOnScrollListener(new NewsListOnScrollListener()); } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { System.out.println("获取信息失败……"); System.out.println("error是" + error.toString()); } }); System.out.println("jsonObjectRequest" + jsonObjectRequest.toString()); return jsonObjectRequest; }
Example 20
Source File: EssayCommentActivity.java From WeCenterMobile-Android with GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.comment_list); ActionBar actionBar = getActionBar(); actionBar.setIcon(null); actionBar.setTitle("��������"); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.show(); Intent intent = getIntent(); id = intent.getStringExtra("artid"); client = new AsyncHttpClient(); myCookieStore = new PersistentCookieStore(this); client.setCookieStore(myCookieStore); comment = (EditText) findViewById(R.id.comment); publish = (ImageButton) findViewById(R.id.publish); publish.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub RequestParams params = new RequestParams(); params.put("article_id", id); params.put("message", comment.getText().toString()); params.put("at_uid", atuid); postcom(params); comment.setText(""); refresh(); } }); comitems = new ArrayList<EssayCommentModel>(); imageDownLoader = new ImageDownLoader(this); comlist = (ListView) findViewById(R.id.comlist); isFirstEnter = true; comlist.setOnItemClickListener(this); comlist.setOnScrollListener(this); Getcom(id); }