Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <GridLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/Grid"
- android:layout_marginLeft="8dp"
- android:layout_marginRight="6dp"
- android:layout_marginBottom="30dp"
- android:layout_gravity="center">
- <LinearLayout android:layout_width="50dp"
- android:layout_height="50dp"
- android:id="@+id/AnswerOne"
- android:orientation="horizontal"
- android:layout_row="0"
- android:layout_column="0"
- >
- <ImageView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/ImageOne"
- />
- </LinearLayout>
- <LinearLayout android:layout_width="50dp"
- android:layout_height="50dp"
- android:id="@+id/AnswerTwo"
- android:orientation="horizontal"
- android:layout_row="0"
- android:layout_column="1"
- >
- <ImageView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:id="@+id/ImageTwo"/>
- </LinearLayout>
- Images[0].setOnDragListener(new View.OnDragListener() {
- @Override
- public boolean onDrag(View v, DragEvent event) {
- clipDataImage = GameBoardOnDragListenerSwitchMethod(event, v, 0);
- return clipDataImage ;
- }
- });
- Images[1].setOnDragListener(new View.OnDragListener() {
- @Override
- public boolean onDrag(View v, DragEvent event) {
- clipDataImage = GameBoardOnDragListenerSwitchMethod(event, v, 1);
- return clipDataImage ;
- }
- });
- public boolean GameBoardOnDragListenerSwitchMethod(DragEvent myDrag, View myV, int dragListenerValue){
- switch (myDrag.getAction()) {
- case DragEvent.ACTION_DRAG_STARTED:
- if (myDrag.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
- myV.invalidate();
- return true;
- }
- return true;
- case DragEvent.ACTION_DRAG_ENTERED:
- gameImages[dragListenerValue].setBackgroundColor(Color.BLUE);
- gameImages[dragListenerValue].setPadding(5, 5, 5, 5);
- return true;
- case DragEvent.ACTION_DRAG_LOCATION:
- return true;
- case DragEvent.ACTION_DRAG_EXITED:
- gameImages[dragListenerValue].setBackgroundColor(0);
- gameImages[dragListenerValue].setPadding(0, 0, 0, 0);
- return true;
- case DragEvent.ACTION_DROP:
- DragEvent myEvent = myDrag;
- getGameImages(myEvent, dragListenerValue);
- return true;
- case DragEvent.ACTION_DRAG_ENDED:
- return true;
- // An unknown action type was received.
- default:
- Log.e("DragDrop Example", "Unknown action type received by OnDragListener.");
- break;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement