本文整理汇总了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();
}
示例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;
}