【问题标题】:How to make a gallery? [closed]如何制作画廊? [关闭]
【发布时间】:2016-03-17 00:47:53
【问题描述】:

您好 :) 我花了几个月的时间解决这个问题,我已经阅读了文档。

https://creativesdk.adobe.com/docs/android/#/articles/gettingstarted/index.html

My application

图片连接到一个url:/

我想知道如何放置一个图库,并且用户可以选择图像以便您进行编辑,相机也是如此。

【问题讨论】:

    标签: android android-studio aviary adobecreativesdk


    【解决方案1】:

    你可以从谷歌画廊学习,这里是源代码https://android.googlesource.com/platform/packages/apps/Gallery2/

    【讨论】:

    • 我应该把它放在哪里? ://
    • 这是一个完整的项目,您必须先阅读代码,看看哪个部分适合您的项目,然后复制该部分并在您的项目中进行一些更改。
    【解决方案2】:

    启动图库

    如果你想从设备的图库中选择一张图片,你可以这样做:

    Intent galleryPickerIntent = new Intent();
    galleryPickerIntent.setType("image/*");
    galleryPickerIntent.setAction(Intent.ACTION_GET_CONTENT);
    
    startActivityForResult(Intent.createChooser(galleryPickerIntent, "Select an Image"), 203); // Can be any int
    

    这会启动一个新活动,我们希望它会给我们一些结果(在这种情况下,它将是一个图像Uri)。

    一个常见的用例是在用户单击按钮时启动图库:

    View.OnClickListener openGalleryButtonListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent galleryPickerIntent = new Intent();
            galleryPickerIntent.setType("image/*");
            galleryPickerIntent.setAction(Intent.ACTION_GET_CONTENT);
    
            startActivityForResult(Intent.createChooser(galleryPickerIntent, "Select an Image"), 203); // Can be any int
        }
    };
    mOpenGalleryButton.setOnClickListener(openGalleryButtonListener);
    

    此代码将直接打开图库,或首先向用户显示一个选择器,让他们选择将哪个应用用作图像源。

    接收结果

    要接收用户选择的图像,我们将使用onActivityResult() 方法:

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mAuthSessionHelper.onActivityResult(requestCode, resultCode, data);
    
        if (resultCode == RESULT_OK && requestCode == 203) { // the int we used for startActivityForResult()
    
            // You can do anything here. This is just an example.
            mSelectedImageUri = data.getData();
            mSelectedImageView.setImageURI(mSelectedImageUri);
    
        }
    }
    

    我在if 块中放了一些示例代码,但你在那里做什么将取决于你的应用程序。

    【讨论】:

      猜你喜欢
      • 2018-01-20
      • 2012-03-17
      • 1970-01-01
      • 2013-01-17
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      • 1970-01-01
      • 2010-12-11
      相关资源
      最近更新 更多