In this Android Application I used draggable grid view library. The purpose of this application demonstrate how to populate a file from assets folder. If you want to populate more than one resource, you can create a Bitmap ArrayList and add every bitmap’s file path into this arraylist. If you want to you drawable folders instead of assets, check this link: >>>developer.android.com/guide/topics/ui/layout/gridview.html
ScreenShots
image populated version from Assets directory
a drag-and-drop scrolling grid view
Here is more information about DraggableGridView:
-yakdere
To start using DraggableGridView:
-
Place libs/DraggableGridView.jar into your project’s directory and add it to the build path (www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29)
-
Add an import to the activity you’d like to use it in: import com.animoto.android.views.*;
-
Add the view to your activity’s layout XML and save it:
<com.animoto.android.views.DraggableGridView android:id="@+id/dgv" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"> </com.animoto.android.views.DraggableGridView>
-
Obtain a reference to the view to use in code:
public class DraggableGridViewSampleActivity extends Activity { DraggableGridView dgv; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); dgv = ((DraggableGridView)findViewById(R.id.dgv)); }
-
You’re done! You can start adding any type of view you’d like.
TextView tv = new TextView(this); tv.setText("Hello world!"); dgv.addView(tv);
-
Tap and hold a view to begin moving it! Drag it between other views to rearrange them, and drop them in place.
-
Scales nicely to any screen size or resolution
-
Animates smoothly to indicate the rearrangement of children
-
Performs well, even with hundreds of children
-
Becomes scrollable when it contains more children than are visible
-
Can scroll even when a child is being dragged: just bring it to the very top or bottom
-
Easy to modify or extend!
The included project is an Android version of magnetic poetry, which you may have seen covering an eccentric friend’s refrigerator. It creates an OnRearrangeListener for its DraggableGridView which manipulates an ArrayList of strings.
If you’d rather not have to separately keep track of the grid’s elements, I suggest creating your own type of View that contains any information you need about the children and collecting this information from the DraggableGridView when you need it:
String[] words = new String[dgv.getChildCount()]; for (int i = 0; i < words.length; i++) words[i] = ((CustomView)dgv.getChildAt(i)).word;
-
Remove scrolling timer
-
Improve performance