Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gridview.setOnTouchListener(new OnTouchListener() {
- public boolean onTouch(View v, MotionEvent me) {
- int action = me.getActionMasked();
- float currentXPosition = me.getX();
- float currentYPosition = me.getY();
- int position = gridview.pointToPosition((int) currentXPosition,
- (int) currentYPosition);
- if (action == MotionEvent.ACTION_UP) {
- /*Toast.makeText(activity,
- "Item Position : " + position + "Action Up",
- Toast.LENGTH_LONG).show();*/
- //v.setBackgroundColor(activity.getResources().getColor(R.color.red));
- }
- if (action == MotionEvent.ACTION_DOWN) {
- /*Toast.makeText(activity,
- "Item Position : " + position + "Action Down",
- Toast.LENGTH_LONG).show();*/
- downPosition = position;
- //v.setBackgroundColor(activity.getResources().getColor(R.color.red));
- }
- if (action == MotionEvent.ACTION_MOVE) {
- /*Toast.makeText(activity,
- "Item Position : " + position + "Action Move",
- Toast.LENGTH_LONG).show();*/
- if(position>downPosition)
- {
- for(int i = downPosition; i<position; i++)
- {
- gridview.getChildAt(i+1).findViewById(R.id.date).setBackgroundColor(activity.getResources().getColor(R.color.red));
- }
- }else{
- for(int i = position; i<downPosition ; i++)
- {
- gridview.getChildAt(i).findViewById(R.id.date).setBackgroundColor(activity.getResources().getColor(R.color.red));
- }
- }
- }
- return true;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement