当前位置: 首页>>代码示例>>Java>>正文


Java ListViewAutoScrollHelper类代码示例

本文整理汇总了Java中android.support.v4.widget.ListViewAutoScrollHelper的典型用法代码示例。如果您正苦于以下问题:Java ListViewAutoScrollHelper类的具体用法?Java ListViewAutoScrollHelper怎么用?Java ListViewAutoScrollHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ListViewAutoScrollHelper类属于android.support.v4.widget包,在下文中一共展示了ListViewAutoScrollHelper类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.support.v4.widget.ListViewAutoScrollHelper; //导入依赖的package包/类
private void init() {
        listView = (ListView) findViewById(R.id.list_view);

        String[] strs = getData(100);
        List<Map<String, Object>> list = new ArrayList<>();
        for (String str : strs) {
            Map<String, Object> map = new HashMap<>();
            map.put("text", str);
            list.add(map);
        }
        SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.item_simple, new String[]{"text"}, new int[]{R.id.text_view});
        listView.setAdapter(adapter);

        AutoScrollHelper autoScrollHelper = new ListViewAutoScrollHelper(listView);
        listView.setOnTouchListener(autoScrollHelper);
        autoScrollHelper.setEnabled(true);
//        autoScrollHelper.setActivationDelay(3000);
//        autoScrollHelper.setRampDownDuration(3000);
        Toast.makeText(this, "长按上或下边缘", Toast.LENGTH_SHORT).show();
    }
 
开发者ID:zhengxiaopeng,项目名称:Rocko-Android-Demos,代码行数:21,代码来源:ListViewActivity.java

示例2: onForwardedEvent

import android.support.v4.widget.ListViewAutoScrollHelper; //导入依赖的package包/类
public boolean onForwardedEvent(MotionEvent event, int activePointerId) {
    boolean handledEvent = true;
    boolean clearPressedItem = false;
    int actionMasked = MotionEventCompat.getActionMasked(event);
    switch (actionMasked) {
        case 1:
            handledEvent = false;
            break;
        case 2:
            break;
        case 3:
            handledEvent = false;
            break;
    }
    int activeIndex = event.findPointerIndex(activePointerId);
    if (activeIndex < 0) {
        handledEvent = false;
    } else {
        int x = (int) event.getX(activeIndex);
        int y = (int) event.getY(activeIndex);
        int position = pointToPosition(x, y);
        if (position == -1) {
            clearPressedItem = true;
        } else {
            View child = getChildAt(position - getFirstVisiblePosition());
            setPressedItem(child, position, (float) x, (float) y);
            handledEvent = true;
            if (actionMasked == 1) {
                clickPressedItem(child, position);
            }
        }
    }
    if (!handledEvent || clearPressedItem) {
        clearPressedItem();
    }
    if (handledEvent) {
        if (this.mScrollHelper == null) {
            this.mScrollHelper = new ListViewAutoScrollHelper(this);
        }
        this.mScrollHelper.setEnabled(true);
        this.mScrollHelper.onTouch(this, event);
    } else if (this.mScrollHelper != null) {
        this.mScrollHelper.setEnabled(false);
    }
    return handledEvent;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:47,代码来源:ListPopupWindow.java


注:本文中的android.support.v4.widget.ListViewAutoScrollHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。