Quick Start
The No. 0 step is to add the module Multi-image-selector as your project dependencies to the project.
The 1th step is to add permission Android.permission.READ_EXTERNAL_STORAGE to your Androidmanifest.xml file. Don't forget to declare multiimageselectoractivity this activity in Androidmanifest.xml.
<activity
android:configchanges= "orientation|screensize"
android:name= "Me.nereo.multi_image_ Selector. Multiimageselectoractivity "/>
The 2nd step of the code is called, for example:
Intent Intent = new Intent (Mcontext, multiimageselectoractivity.class);
Whether to show call camera
to take picture Intent.putextra (Multiimageselectoractivity.extra_show_camera, true);
Maximum picture selection number
Intent.putextra (Multiimageselectoractivity.extra_select_count, 9);
Setup mode (supports radio/multiimageselectoractivity.mode_single or multiple selection/multiimageselectoractivity.mode_multi)
Intent.putextra (Multiimageselectoractivity.extra_select_mode, multiimageselectoractivity.mode_multi);
Startactivityforresult (Intent, request_image);
The 3rd step is to accept the result in your Onactivityresult method. For example:
@Override
protected void onactivityresult (int requestcode, int resultcode, Intent data) {
Super.onactivityresult (Requestcode, ResultCode, data);
if (Requestcode = = request_image) {
if (ResultCode = = RESULT_OK) {
//Get the Returned picture List
list<string> path = Data.getstringarraylistextra (Multiimageselectoractivity.extra_result);
Deal with your own logic ....}}
The 4th step is not 4th step, so it is OK ~:)
Custom Displaycustomizing activity
Class Customeractivity extends Activity implements multiimageselectorfragment.callback{@Override protected void O
Ncreate (Bundle savedinstancestate) {//Your own logic ...
Bundle bundle = new bundle ();
Bundle.putint (Multiimageselectorfragment.extra_select_count, Mdefaultcount);
Bundle.putint (Multiimageselectorfragment.extra_select_mode, MODE);
<bundle class= "Putbo" ></bundle>olean (Multiimageselectorfragment.extra_show_camera, isShow); Add main fragment to Activity Getsupportfragmentmanager (). BeginTransaction (). Add (R.id.image_grid, FRAGM
Ent.instantiate (this, MultiImageSelectorFragment.class.getName (), bundle)). commit (); } @Override public void onsingleimageselected (String path) {//When the selection mode is set to Radio/mode_single, this method will accept fragment
The returned data} @Override public void onimageselected (String path) {//A picture is selected to be triggered, and here you can customize your own actionbar behavior } @Override Public VOID onimageunselected (String path) {//A picture being reversed is triggered, and here you can customize your own Actionbar behavior} @Override public void OnC Amerashot (file ImageFile) {//When the camera is set, the user will return a photo file after taking a picture}}
Specifically, you can refer to the implementation of Multiimageselectoractivity.java