onTouchEvent在BaseAdapter的Android [英] onTouchEvent in a BaseAdapter Android
本文介绍了onTouchEvent在BaseAdapter的Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的计划,我必须在BaseAdapter组件插入此onTouchEvent方法:
In my program I must insert this onTouchEvent method in a BaseAdapter component:
public class FlipAdapter extends BaseAdapter {
...
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
startY = event.getY();
break;
}
case MotionEvent.ACTION_UP: {
float endY = event.getY();
if (endY > startY) {
layoutComments.startAnimation(animDown);
layoutComments.setVisibility(View.GONE);
}
}
}
return true;
}
这个功能在活动工作(这是正确的),但在此组件它不是作品。我认为问题在于layoutComments插入到ViewHolder,但我无法通过视图的onTouchEvent。任何想法?
This function works in an Activity (it's right) but in this component it's not works. I think that the problem is that the layoutComments is inserted in a ViewHolder, but I can't pass the view to the onTouchEvent. Any ideas?
推荐答案
请按照如下:
public class YourClassName extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
.......
}
class FlipAdapter extends BaseAdapter
{
//Now you can access everything from the activity.
}
}
希望这会帮助你。
Hope this will help you.
这篇关于onTouchEvent在BaseAdapter的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文