Android Open Source - Gui2Go Grid View Item Click Listener

From Project

Back to project page Gui2Go.


The source code is released under:

MIT License

If you think the Android project Gui2Go listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ami.gui2go;
/*from  w w  w .  j  a  va  2  s.c  o m*/
import android.content.ClipData;
import android.content.ClipDescription;
import android.view.View;
import android.view.View.DragShadowBuilder;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.AdapterView.OnItemLongClickListener;

public class GridViewItemClickListener implements OnItemLongClickListener
  public boolean onItemLongClick(AdapterView<?> parent, View v,
      int position, long id)
    LinearLayout lay = (LinearLayout) v;
    String tag = (String) ((TextView) lay.getChildAt(0)).getText();
    String[] mimeTypes = { ClipDescription.MIMETYPE_TEXT_PLAIN };

    ClipData.Item item = new ClipData.Item(tag);
    ClipData dragData = new ClipData("GridViewItem", mimeTypes, item);

    View.DragShadowBuilder myShadow = new DragShadowBuilder(v);

    v.startDrag(dragData, myShadow, null, 0);
    return true;

Java Source Code List