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

    xiaoxiao2021-12-12  6

    运行效果: 

    使用说明: 

    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"/>

    转载请注明原文地址: https://ju.6miu.com/read-900002.html

    最新回复(0)