• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

development


Commit MetaInfo

Revision86e2451d1c49263bd3a761fe16ab2769d7d634bb (tree)
Time2011-01-15 05:40:37
AuthorChristopher Tate <ctate@goog...>
CommiterAndroid Git Automerger

Log Message

am eb3c9bb4: am 560094ef: Merge "Add a dynamically-revealed view to the drag demo" into honeycomb

* commit 'eb3c9bb439166ef17450e4e9fb4d8fa2d96b6ef3':

Add a dynamically-revealed view to the drag demo

Change Summary

Incremental Difference

--- a/samples/ApiDemos/res/layout/drag_layout.xml
+++ b/samples/ApiDemos/res/layout/drag_layout.xml
@@ -62,6 +62,18 @@
6262 dot:anr="drop"
6363 />
6464
65+ <com.example.android.apis.view.DraggableDot
66+ android:id="@+id/drag_dot_hidden"
67+ android:layout_width="wrap_content"
68+ android:layout_height="wrap_content"
69+ dot:radius="64dp"
70+ android:padding="15dp"
71+ android:layout_toRightOf="@id/drag_dot_3"
72+ android:layout_alignTop="@id/drag_dot_3"
73+ android:visibility="invisible"
74+ dot:legend="Surprise!"
75+ />
76+
6577 <TextView android:id="@+id/drag_result_text"
6678 android:layout_width="fill_parent"
6779 android:layout_height="wrap_content"
--- a/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.java
@@ -26,6 +26,7 @@ import android.widget.TextView;
2626
2727 public class DragAndDropDemo extends Activity {
2828 TextView mResultText;
29+ DraggableDot mHiddenDot;
2930
3031 @Override
3132 protected void onCreate(Bundle savedInstanceState) {
@@ -40,14 +41,30 @@ public class DragAndDropDemo extends Activity {
4041 dot = (DraggableDot) findViewById(R.id.drag_dot_3);
4142 dot.setReportView(text);
4243
44+ mHiddenDot = (DraggableDot) findViewById(R.id.drag_dot_hidden);
45+ mHiddenDot.setReportView(text);
46+
4347 mResultText = (TextView) findViewById(R.id.drag_result_text);
4448 mResultText.setOnDragListener(new View.OnDragListener() {
4549 @Override
4650 public boolean onDrag(View v, DragEvent event) {
4751 final int action = event.getAction();
48- if (action == DragEvent.ACTION_DRAG_ENDED) {
49- final boolean dropped = event.getResult();
50- mResultText.setText(dropped ? "Dropped!" : "No drop");
52+ switch (action) {
53+ case DragEvent.ACTION_DRAG_STARTED: {
54+ // Bring up a fourth draggable dot on the fly. Note that it
55+ // is properly notified about the ongoing drag, and lights up
56+ // to indicate that it can handle the current content.
57+ mHiddenDot.setVisibility(View.VISIBLE);
58+ } break;
59+
60+ case DragEvent.ACTION_DRAG_ENDED: {
61+ // Hide the surprise again
62+ mHiddenDot.setVisibility(View.INVISIBLE);
63+
64+ // Report the drop/no-drop result to the user
65+ final boolean dropped = event.getResult();
66+ mResultText.setText(dropped ? "Dropped!" : "No drop");
67+ } break;
5168 }
5269 return false;
5370 }