0
我有一个水平的图像列表。我想,如果我长按图像,然后尝试拖动图像,然后...长按情况下如何停止水平滚动
我有一个水平的图像列表。我想,如果我长按图像,然后尝试拖动图像,然后...长按情况下如何停止水平滚动
扩展图库类并重写onLongPress(MotionEvent e)方法,并在那里您将图库视图放置在xml位置上课。
像下面
package com.prac;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.Gallery;
import android.widget.Toast;
public class MyGallery extends Gallery {
private Context mContext;
public MyGallery(Context context) {
super(context);
mContext = context;
// TODO Auto-generated constructor stub
}
public MyGallery(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
// TODO Auto-generated constructor stub
}
public MyGallery(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
// TODO Auto-generated constructor stub
}
@Override
public boolean onLongPress(MotionEvent e)
{
// do what ever you want on Long Press Here
return false;
}
}
现在你的XML布局应该是这样的
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.prac.MyGallery
android:id="@+id/Gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
希望它能帮助:)如果它可以帮助你,不要忘记通过单击箭头接受答案在回答的左侧,并使其变成绿色
不完整的问题......写完成问题。或者你必须清楚你的问题 – Nikki 2011-02-16 11:58:48