Java Code Examples for android.widget.ListView.setOnScrollListener()

The following are Jave code examples for showing how to use setOnScrollListener() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: SampleListDetailActivity.java   View Source Code Vote up 6 votes
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
  final SampleListDetailActivity activity = (SampleListDetailActivity) getActivity();
  final SampleListDetailAdapter adapter = new SampleListDetailAdapter(activity);

  ListView listView = (ListView) LayoutInflater.from(activity)
      .inflate(R.layout.sample_list_detail_list, container, false);
  listView.setAdapter(adapter);
  listView.setOnScrollListener(new SampleScrollListener(activity));
  listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
      String url = adapter.getItem(position);
      activity.showDetails(url);
    }
  });
  return listView;
}
 
Example 2
Project: yyox   File: FeedBackDetailsActivity.java   View Source Code Vote up 6 votes
@Override
protected void initWidgets() {
    super.initWidgets();
    mLayoutBottom = (RelativeLayout) findViewById(R.id.kf5_bottom_layout);
    mFeedBackDetailBottomView = new FeedBackDetailBottomView(mActivity);
    mFeedBackDetailBottomView.setListener(this);
    mETContent = layoutListener.getEditText();
    mLayoutBottom.addView(mFeedBackDetailBottomView);
    mListView = (ListView) findViewById(R.id.kf5_activity_feed_back_details_listview);
    mListView.setOnScrollListener(this);
    mListView.setOnItemLongClickListener(this);
    mListView.addHeaderView(inflateHeaderView());
    mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImg.setOnClickListener(this);
    mRightView = (TextView) findViewById(R.id.kf5_right_text_view);
    mRightView.setOnClickListener(this);
}
 
Example 3
Project: LoadMoreHelper   File: MultiScrollListener.java   View Source Code Vote up 6 votes
public static void addScrollListener(ListView listview, OnScrollListener listener){
    if (listview == null || listener == null)  {
        return;
    }
    OnScrollListener originListener = getScrollListenerFromListView(listview);
    if (originListener instanceof MultiScrollListener) {
        (((MultiScrollListener)originListener)).addListener(listener);
    } else {
        MultiScrollListener multiScrollListener = new MultiScrollListener();
        if (originListener != null) {
            multiScrollListener.addListener(originListener);
        }
        multiScrollListener.addListener(listener);
        listview.setOnScrollListener(multiScrollListener);
    }
}
 
Example 4
Project: LoadMoreHelper   File: MultiScrollListener.java   View Source Code Vote up 6 votes
public static void removeScrollListener(ListView listview, OnScrollListener listener) {
    if (listview == null || listener == null) {
        return;
    }
    OnScrollListener originListener = getScrollListenerFromListView(listview);
    if (originListener == listener) {
        listview.setOnScrollListener(null);
    } else {
        if (originListener instanceof MultiScrollListener) {
            MultiScrollListener multiScrollListener = (MultiScrollListener)originListener;
            multiScrollListener.removeListener(listener);
            if (multiScrollListener.isEmpty()) {
                listview.setOnScrollListener(null);
            }
        }
    }
}
 
Example 5
Project: sctalk   File: ContactFragment.java   View Source Code Vote up 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 6
Project: GitHub   File: CustomSwipeRefreshLayout.java   View Source Code Vote up 5 votes
/**
 * 获取ListView对象
 */
private void getListView() {
    int childs = getChildCount();
    if (childs > 0) {
        View childView = getChildAt(0);
       if (childView instanceof ListView) {
            mInternalListView = (ListView) childView;
            // 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载
            mInternalListView.setOnScrollListener(this);
            Log.d("zttjiangqq","存在listview...");
        }else{
            Log.d("zttjiangqq","不存在listview...");
        }
    }
}
 
Example 7
Project: GitHub   File: SampleContactsActivity.java   View Source Code Vote up 5 votes
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.sample_contacts_activity);

  adapter = new SampleContactsAdapter(this);

  ListView lv = (ListView) findViewById(android.R.id.list);
  lv.setAdapter(adapter);
  lv.setOnScrollListener(new SampleScrollListener(this));

  getSupportLoaderManager().initLoader(ContactsQuery.QUERY_ID, null, this);
}
 
Example 8
Project: Fahrplan   File: SearchResultActivity.java   View Source Code Vote up 5 votes
public void setResult(List<Connection> result) {
    if(connections == null) {
        connections = result;
    } else {
        connections.addAll(result);
    }
    if(adapter == null) {
        ListView listView = (ListView)findViewById(R.id.result_list);
        adapter = new ConnectionAdapter(this, result);
        listView.setAdapter(adapter);
        listView.setOnScrollListener(new SearchResultScrollListener(this, query));
    } else {
        adapter.notifyDataSetChanged();
    }
}
 
Example 9
Project: SunmiUI   File: PullToRefreshSwipeLayout.java   View Source Code Vote up 5 votes
private void getListView() {
    int childCount = getChildCount();
    if (childCount > 0) {
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (child instanceof ListView) {
                mListView = (ListView) child;
                // 设置滚动监听器给ListView, 使得滚动到底部可以自动加载
                mListView.setOnScrollListener(onScrollListener);
                break;
            }
        }
    }
}
 
Example 10
Project: Mount   File: MountActivity.java   View Source Code Vote up 5 votes
private void setupListView() {
    mListView = (ListView) findViewById(R.id.list);

    mPackageList = new ArrayList<>();
    mPackageAdapter = new PackageItemAdapter(this, mPackageList);
    mListView.setAdapter(mPackageAdapter);
    mListView.setHeaderDividersEnabled(false);

    mListView.setOnScrollListener(this); // not show fast scroll always
    mListView.setOnItemClickListener(this);
}
 
Example 11
Project: Sortable_tableview_soussidev   File: TableView.java   View Source Code Vote up 5 votes
private void setupTableDataView(final AttributeSet attributes, final int styleAttributes) {
    final LayoutParams dataViewLayoutParams = new LayoutParams(getWidthAttribute(attributes), LayoutParams.MATCH_PARENT);

    if (isInEditMode()) {
        tableDataAdapter = new EditModeTableDataAdapter(getContext());
    } else {
        tableDataAdapter = new DefaultTableDataAdapter(getContext());
    }
    tableDataAdapter.setRowBackgroundProvider(dataRowBackgroundProvider);

    tableDataView = new ListView(getContext(), attributes, styleAttributes);

    tableDataView.setOnItemClickListener(new InternalDataClickListener());
    tableDataView.setOnItemLongClickListener(new InternalDataLongClickListener());
    tableDataView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    tableDataView.setAdapter(tableDataAdapter);
    tableDataView.setId(R.id.table_data_view);
    tableDataView.setOnScrollListener(new InternalOnScrollListener());

    swipeRefreshLayout = new SwipeRefreshLayout(getContext());
    swipeRefreshLayout.setLayoutParams(dataViewLayoutParams);
    swipeRefreshLayout.addView(tableDataView);
    swipeRefreshLayout.setColorSchemeColors(headerColor);
    swipeRefreshLayout.setEnabled(false);

    addView(swipeRefreshLayout);
}
 
Example 12
Project: OSchina_resources_android   File: SoftwareCatalogListFragment.java   View Source Code Vote up 5 votes
private void initViews(View view) {
    mScrollLayout = (ScrollLayout) view.findViewById(R.id.scrolllayout);
    mScrollLayout.setIsScroll(false);

    mEmptyView = (EmptyLayout) view.findViewById(R.id.error_layout);
    mLvCatalog = (ListView) view.findViewById(R.id.lv_catalog);
    mLvCatalog.setOnItemClickListener(mCatalogOnItemClick);
    mLvTag = (ListView) view.findViewById(R.id.lv_tag);
    mLvTag.setOnItemClickListener(mTagOnItemClick);
    if (mCatalogAdapter == null) {
        mCatalogAdapter = new SoftwareCatalogListAdapter();
        sendRequestCatalogData(mCatalogHandler);
    }
    mLvCatalog.setAdapter(mCatalogAdapter);

    if (mTagAdapter == null) {
        mTagAdapter = new SoftwareCatalogListAdapter();
    }
    mLvTag.setAdapter(mTagAdapter);

    if (mSoftwareAdapter == null) {
        mSoftwareAdapter = new SoftwareAdapter();
    }

    mLvSoftware = (ListView) view.findViewById(R.id.lv_software);
    mLvSoftware.setOnItemClickListener(this);
    mLvSoftware.setOnScrollListener(this);
    mLvSoftware.setAdapter(mSoftwareAdapter);
}
 
Example 13
Project: OSchina_resources_android   File: SuperRefreshLayout.java   View Source Code Vote up 5 votes
/**
 * 获取ListView并添加Footer
 */
private void getListView() {
    int child = getChildCount();
    if (child > 0) {
        View childView = getChildAt(0);
        if (childView instanceof ListView) {
            mListView = (ListView) childView;
            // 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载
            mListView.setOnScrollListener(this);
        }
    }
}
 
Example 14
Project: MaterialDesignDemo   File: TransparentToolbarActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transparent_toolbar);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    mScreenHeight = getResources().getDisplayMetrics().heightPixels;
    Log.e("CSDN_LQR", "screenHeight = " + mScreenHeight);
    mLv = (ListView) findViewById(R.id.lv);
    mLv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, Cheeses.NAMES));
    mLv.setOnScrollListener(this);
}
 
Example 15
Project: TPlayer   File: SuperRefreshLayout.java   View Source Code Vote up 5 votes
/**
 * 获取ListView并添加Footer
 */
private void getListView() {
    int child = getChildCount();
    if (child > 0) {
        View childView = getChildAt(0);
        if (childView instanceof ListView) {
            mListView = (ListView) childView;
            // 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载
            mListView.setOnScrollListener(this);
        }
    }
}
 
Example 16
Project: sctalk   File: ChatFragment.java   View Source Code Vote up 5 votes
private void initContactListView() {
    contactListView = (ListView) curView.findViewById(R.id.ContactListView);
    contactListView.setOnItemClickListener(this);
    contactListView.setOnItemLongClickListener(this);
    contactAdapter = new  ChatAdapter(getActivity());
    contactListView.setAdapter(contactAdapter);

    // this is critical, disable loading when finger sliding, otherwise
    // you'll find sliding is not very smooth
    contactListView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(),
            true, true));
}
 
Example 17
Project: aos-Video   File: AutoScraperActivity.java   View Source Code Vote up 4 votes
@Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        getWindow().setFlags(LayoutParams.FLAG_NOT_TOUCH_MODAL, LayoutParams.FLAG_NOT_TOUCH_MODAL);
        getWindow().setFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);

        // Notify the application that the activity has started
        CustomApplication app = (CustomApplication)getApplication();
        app.setAutoScraperActive(true);
        mScraper = new Scraper(this);

        // Check if the intent which created this activity contains a folder path
        Uri folderUri = getIntent().getData();
        if (folderUri != null) {
            mFolderMode = true;
            // FIXME: this is broken for smb:// files
            mFolderPath = folderUri.getPath();
            if (DBG) Log.d(TAG, "onCreate : search in folder " + mFolderPath);
        }
        else {
            mFolderMode = false;
            mFolderPath = null;
            if (DBG) Log.d(TAG, "onCreate : search in the full database");
        }

        setContentView(R.layout.auto_scraper_main);

        mMainView = findViewById(R.id.main_view);
        mAbortButton = (Button)findViewById(R.id.abort_button);
        mAbortButton.setOnClickListener(this);
        mExitButton = (Button)findViewById(R.id.exit_button);
        mExitButton.setOnClickListener(this);

        mListView = (ListView) findViewById(R.id.list_items);
        mListView.setTextFilterEnabled(true);
        mListView.setCacheColorHint(0);
        mListView.setSelector(R.drawable.list_selector_no_background);
        mListView.setOnCreateContextMenuListener(this);
        mListView.setOnScrollListener(this);
        mListView.setOnKeyListener(this);

        mActivityFileCursor = getFileListCursor();
        getColumnIndices(mActivityFileCursor);
        buildFileProperties(mActivityFileCursor);
        mAdapterFileCursor = buildAdapterCursor(mActivityFileCursor);

        mAdapter = new AutoScraperAdapter(getApplication(), this,
                                          R.layout.auto_scraper_item,
                                          mAdapterFileCursor);
        mListView.setAdapter(mAdapter);
/*
        if (!mListView.isInTouchMode()) {
            // The application is remotely controlled => set the focus by default
            // on the Cancel button so that the user can abort the task with a 
            // single click instead of navigating the full ListView
            mAbortButton.requestFocus();
        }
*/
        mEmptyView = buildEmptyView();
        mListView.setEmptyView(mEmptyView);
        updateControlButtons(false);
        if (mFileCount > 0) {
            mMainView.setVisibility(View.VISIBLE);
        }
        else {
            mMainView.setVisibility(View.GONE);
        }

        mIsLargeScreen = getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)|| TVUtils.isTV(this);

        PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "AutoScraperActivity");
    }
 
Example 18
Project: CustomAndroidOneSheeld   File: ListViewScrollObserver.java   View Source Code Vote up 4 votes
public ListViewScrollObserver(ListView listView) {
    listView.setOnScrollListener(this);
}