通过滑动为GridView设置动画项

时间:2013-11-08 09:58:36

标签: android android-arrayadapter

我需要通过滑动从gridView获取tile并将其设置为动画以显示其下方的按钮。如何让视图用它进行一些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;
}

}

0 个答案:

没有答案