我有一个ImageView.当您单击ImageView时,它将打开图库,您将获取图像并在ImageView上显示它.我有一个条件,当我关闭我的应用程序,然后我打开它,图像将保留在那里.所以,为此,我将图像Uri存储在sharedprefrence上.在打开应用程序时,我正在检索相同的Uri并尝试在imageView上显示图像.
然而在一些手机中 - 图像看起来像Mi(Lollipop),三星(KitKat)一样完美,但它并没有出现在像摩托罗拉(Marshmallow),One Plus One(Marshmallow)这样的手机中.知道为什么会这样吗?这是我的代码
拿起我正在使用的图像
Intent intent=new Intent();intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), Constants.SELECT_PICTURE);
Run Code Online (Sandbox Code Playgroud)
在OnActivityResult()代码上
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==Constants.SELECT_PICTURE && resultCode==RESULT_OK && null!=data) {
Uri uri=data.getData();
Picasso.with(UsersProfileActivity.this)
.load(uri)
.centerCrop()
.resize(200,200)
.into(img_photo);
// This profile image i am storing into a sharedpreference
profile_image=uri.toString();
}
Run Code Online (Sandbox Code Playgroud)
在从sharedprefrence检索时,我通过使用将String转换为uri Uri.parse(profile_image)
但是如果我注意到,uri为不同的Android手机返回如下
Mi(Lollipop)- Uri=content://media/external/images/media/12415
samsung(KitKat)-Uri=content://media/external/images/media/786
Motorola(Marshmallow)- Uri=content://com.android.providers.media.documents/document/image%3A30731
One Plus One (Marshmallow)- Uri=content://com.android.providers.media.documents/document/image%3A475
Run Code Online (Sandbox Code Playgroud)
因此,当uri内容是-content:// media/external/images/media /是在ImageView Perfect上显示图像时,在其他情况下它不是
我正在VB.NET 2010中设计一个基于选择的冒险游戏,在那里你会看到一个故事标签,你可以选择2个按钮,你想要做出哪个选择.我想知道最有效的方法.
我的目标是以某种形式的数据结构存储按钮和故事的标签,这是暂时的哈希表,以及某种形式的选择结构.现在我使用的是一个自定义类,它引用了下两个选项的索引以及它们各自的标签索引,它们将类实例存储在一个哈希表中.我已经研究了数组,词典,列表和集合等内容,但我不确定哪一个最适合我所追求的内容.任何.NET数据结构都可以.这两个数据的最有效数据结构是什么?只是一个字符串数组工作?