运行效果: 

Android图片选择和浏览组件:PhotoPicker

使用说明: 

 

Gradle 

compile 'me.iwf.photopicker:PhotoPicker:0.1.8'

 

 

 

Pick Photo 

PhotoPickerIntent intent = new PhotoPickerIntent(MainActivity.this);
intent.setPhotoCount(9);
intent.setShowCamera(true);
startActivityForResult(intent, REQUEST_CODE);

 

 

 

onActivityResult 

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) {
        if (data != null) {
            photos =
                    data.getStringArrayListExtra(PhotoPickerActivity.KEY_SELECTED_PHOTOS);
            Toast.makeText(this, "photos大小:"+photos.size(), Toast.LENGTH_SHORT).show();
        }
    }


}

 

 

 

Preview Photo 

 

 

 

Intent intent2 = new Intent(MainActivity.this, PhotoPagerActivity.class);
intent2.putExtra(PhotoPagerActivity.EXTRA_CURRENT_ITEM, 0);
intent2.putExtra(PhotoPagerActivity.EXTRA_PHOTOS, photoPaths);
startActivityForResult(intent2, REQUEST_CODE);

 

 

 

manifest 

 

 

 

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera" android:required="true" />

 

 

 

<activity android:name="me.iwf.photopicker.PhotoPickerActivity"
    android:theme="@style/Theme.AppCompat.NoActionBar"
    />

<activity android:name="me.iwf.photopicker.PhotoPagerActivity"
    android:theme="@style/Theme.AppCompat.NoActionBar"/>

 

 

 

相关文章:

  • 2021-11-15
  • 2021-10-05
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-06-20
猜你喜欢
  • 2021-09-28
  • 2021-11-26
  • 2022-12-23
  • 2021-08-04
  • 2021-07-31
相关资源
相似解决方案