Drag/drop among four big dots on screen. Drags to a dot will have the identity of the originating dot put into a text field below the dots. In all cases, a text field to the right of the dots reports whether the drag ended in a successful drop. Attempting to start a drag from a dot reading "Drag ANR" should ANR and be cleaned up properly. Attempting to drop onto a dot reading "Drop ANR" should similarly ANR and be cleaned up properly. Drags from a dot labelled "Local" are restricted to targets within the app's own window -- they are not draggable to the system "shirt pocket" drop target, etc. A drop onto the same dot that it originated from will append text to that effect to the message that notes the dropped payload. This uses the "local state" convenience mechanism in startDrag() and DragEvent.getLocalState(). Change-Id: Ic5cd6a29186a84c91d3dc4187e83e7bcf530ba2f
94 lines
3.2 KiB
XML
94 lines
3.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- Copyright (C) 2010 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<!-- Layout description of the DragAndDrop sample's main activity -->
|
|
|
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
xmlns:dot="http://schemas.android.com/apk/res/com.example.android.apis"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:orientation="vertical"
|
|
>
|
|
|
|
<TextView android:id="@+id/drag_explanation"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:text="@string/drag_explanation"
|
|
/>
|
|
|
|
<com.example.android.apis.view.DraggableDot
|
|
android:id="@+id/drag_dot_1"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
dot:radius="64dp"
|
|
android:padding="15dp"
|
|
android:layout_below="@id/drag_explanation"
|
|
/>
|
|
|
|
<com.example.android.apis.view.DraggableDot
|
|
android:id="@+id/drag_dot_2"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
dot:radius="64dp"
|
|
android:padding="15dp"
|
|
android:layout_below="@id/drag_explanation"
|
|
android:layout_toRightOf="@id/drag_dot_1"
|
|
dot:legend="Drag ANR"
|
|
dot:anr="thumbnail"
|
|
/>
|
|
|
|
<com.example.android.apis.view.DraggableDot
|
|
android:id="@+id/drag_dot_3"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
dot:radius="64dp"
|
|
android:padding="15dp"
|
|
android:layout_below="@id/drag_dot_1"
|
|
android:layout_alignLeft="@id/drag_dot_1"
|
|
dot:legend="Drop ANR"
|
|
dot:anr="drop"
|
|
/>
|
|
|
|
<com.example.android.apis.view.DraggableDot
|
|
android:id="@+id/drag_dot_4"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
dot:radius="64dp"
|
|
android:padding="15dp"
|
|
android:layout_below="@id/drag_dot_1"
|
|
android:layout_toRightOf="@id/drag_dot_3"
|
|
dot:legend="Local"
|
|
dot:localOnly="true"
|
|
/>
|
|
|
|
<TextView android:id="@+id/drag_result_text"
|
|
android:layout_width="fill_parent"
|
|
android:layout_height="wrap_content"
|
|
android:layout_below="@id/drag_explanation"
|
|
android:layout_alignRight="@id/drag_explanation"
|
|
android:layout_toRightOf="@id/drag_dot_2"
|
|
/>
|
|
|
|
<TextView android:id="@+id/drag_text"
|
|
android:layout_width="fill_parent"
|
|
android:layout_height="fill_parent"
|
|
android:layout_weight="1"
|
|
android:layout_below="@id/drag_dot_3"
|
|
android:layout_alignLeft="@id/drag_dot_3"
|
|
/>
|
|
|
|
</RelativeLayout>
|