小编Ash*_*Ash的帖子

如何将图像上传设置为仅 jpg 和 png 文件?

这是我正在使用的代码,它工作得很好,但我如何只将文件类型设置为 jpg 和 png 并禁止/不显示库中的任何其他图像

private void ButtonOnClick(object sender, EventArgs eventArgs) {
    Intent = new Intent();
    Intent.SetType("image/*");
    Intent.SetAction(Intent.ActionGetContent);
    StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
}

#endregion

#region Get the Path of Selected Image
private string GetPathToImage(Uri uri) {
    string path = null;
    // The projection contains the columns we want to return in our query.
    string[] projection = new[] { 
            Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data };
    using (ICursor cursor = ManagedQuery(uri, projection, null, null, null)) {
        if (cursor != null) {
            int columnIndex = cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
            cursor.MoveToFirst(); …
Run Code Online (Sandbox Code Playgroud)

c# java android xamarin.android xamarin

6
推荐指数
2
解决办法
3139
查看次数

标签 统计

android ×1

c# ×1

java ×1

xamarin ×1

xamarin.android ×1