gv.setOnItemClickListener(new OnItemClickListener() {
@SuppressLint("NewApi")
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
view.setAnimation(AnimationManger.MakeLearAnimation());
if (firstclick) {
startid = position;
firstclick = false;
} else {
firstclick = true;
endid = position;
// 如果是前后点击
if (startid - endid == 1 || endid - startid == 1) {
// 将list中 指定的元素对换位置
Collections.swap(data, startid, endid);
actMainGvAdapter.notifyDataSetChanged();
}
// 如果是上下点击
if (startid - endid == size || endid - startid == size) {
// 将list中 指定的元素对换位置
Collections.swap(data, startid, endid);
actMainGvAdapter.notifyDataSetChanged();
}
}
}
});