【开源】MultipleImagePick

MultipleImagePick

  •  https://github.com/luminousman/MultipleImagePick

    介绍:

    从相册中选择图片,可以单选和多选。

    运行效果:

    使用说明:

    java

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    //选择一张图片
    Intent i = new Intent(Action.ACTION_PICK);
    startActivityForResult(i, 100);
     
    // 选择多张图片
    Intent i = new Intent(Action.ACTION_MULTIPLE_PICK);
    startActivityForResult(i, 200);
     
    @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
     
            if (requestCode == 100 && resultCode == Activity.RESULT_OK) {
                adapter.clear();
     
                viewSwitcher.setDisplayedChild(1);
                String single_path = data.getStringExtra("single_path");
                imageLoader.displayImage("file://" + single_path, imgSinglePick);
     
            else if (requestCode == 200 && resultCode == Activity.RESULT_OK) {
                String[] all_path = data.getStringArrayExtra("all_path");
     
                ArrayList<CustomGallery> dataT = new ArrayList<CustomGallery>();
     
                for (String string : all_path) {
                    CustomGallery item = new CustomGallery();
                    item.sdcardPath = string;
     
                    dataT.add(item);
                }
     
                viewSwitcher.setDisplayedChild(0);
                adapter.addAll(dataT);
            }
        }

    AndroidManifest.xml

    1
    2
    3
    4
    5
    6
    7
    8
     <activity android:name="CustomGalleryActivity" >
                <intent-filter>
                    <action android:name="luminous.ACTION_PICK" />
                    <action android:name="luminous.ACTION_MULTIPLE_PICK" />
     
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
     </activity>

posted on 2015-04-15 10:03  wasdchenhao  阅读(155)  评论(0)    收藏  举报

导航