我需要通过在其上滑动来从 gridView 获取图块并对其进行动画处理以显示其下方的按钮。如何获得视图以使用它进行一些 UI 操作?这是我的活动和适配器代码的片段:
public class HomeActivity extends FragmentActivity {
......
class MyGestureDetector extends SimpleOnGestureListener
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
int position = mGridView.pointToPosition((int) e1.getX(), (int) e1.getY());
if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
View v = mMyAdapter.getView(position, null, mGridView);
v.setVisibility(View.GONE);
}
}
}
}
MyAdapter class:
public class StatusTileAdapter extends ArrayAdapter<MyObject> {
......
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.tile_item, null);
}
MyObject obj = mMyObjects.get(position);
if (mObj != null) {
final ImageView objImage = (ImageView) convertView
.findViewById(R.id.object_image);
final TextView objTitle = (TextView) convertView
.findViewById(R.id.object_title);
objImage.setImageResource(R.drawable.image1);
objTitle.setText(obj.getTitle());
}
}
return convertView;
}
}