Android Studio找不到资源文件

时间:2019-07-08 10:46:49

标签: android android-studio textview

我正在尝试专门寻找def func(a,b): """ Wonderful """ return a+b ,但Android Studio找不到。我应该怎么做才能找到它?我需要此资源,因为我正在在线学习教程。

See here

3 个答案:

答案 0 :(得分:0)

我认为返回下载网址有问题,请尝试以下代码:

private void uploadFile() {
    if (mImageUri != null) {
        StorageReference fileReference = mStorageRef.child(System.currentTimeMillis()
                + "." + getFileExtension(mImageUri));

        fileReference.putFile(mImageUri).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
            @Override
            public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
                if (!task.isSuccessful()) {
                    throw task.getException();
                }

                // Continue with the task to get the download URL
                //change made here
                return fileReference.getDownloadUrl();
            }
        }).addOnCompleteListener(new OnCompleteListener<Uri>() {
            @Override
            public void onComplete(@NonNull Task<Uri> task) {
                if (task.isSuccessful()) {
                    Uri downloadUri = task.getResult();
                        System.out.println("Upload success: " + downloadUri);
                } else {
                    // Handle failures
                    // ...
                }
            }
        });

    } else {
        Toast.makeText(this, "No file selected", Toast.LENGTH_SHORT).show();
    }

}

答案 1 :(得分:0)

所以我有同样的问题。我有一个已经使用了两年的代码,但是Firebase中似乎有所更改。波纹管是一种新的代码,可以解决此问题。 附言:它在kotlin中,但是您可以在参考链接中放入android示例,然后调整到我的代码即可。

首先声明一个全局变量 私人lateinit var filePath:Uri

然后将您的图片放在此uri文件中。

然后转到您要上传的代码:

    mFireBaseStorage = FirebaseStorage.getInstance()
    mphotoStorageReference = mFireBaseStorage.reference  //storage references

    val storageRef = mphotoStorageReference.child("usuarios_img")  //path in storage. This is the folder name in storage

    val bmp: Bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath)
    val baos: ByteArrayOutputStream = ByteArrayOutputStream()
    bmp.compress(Bitmap.CompressFormat.JPEG, 25, baos) //choose compreess rate (100 means no compression)

    //get the uri from the bitmap
    val tempUri: Uri = getImageUri(this, bmp)
    //transform the new compressed bmp in filepath uri
    filePath = tempUri  //filePath is a global variable Uri


   
   var uploadTask = storageRef.child("the_name_of_the_file).putFile(filePath)

    // [START upload_get_download_url]
    val ref = storageRef
    uploadTask = ref.putFile(filePath)

    val urlTask = uploadTask.continueWithTask { task ->
        if (!task.isSuccessful) {
            task.exception?.let {
                throw it
            }
        }
        ref.downloadUrl
    }.addOnCompleteListener { task ->
        if (task.isSuccessful) {
            val downloadUri = task.result
            Log.d("test", "worked, this is the url link "+downloadUri)
            
           
        } else {
            // Handle failures
            Log.d("test", "error")

        }
    }

仅此而已。

参考 https://firebase.google.com/docs/storage/android/upload-files?hl=pt-br

希望它会有所帮助,因为我已经花了几个小时。

答案 2 :(得分:-2)

<style name="Widget.Material.TextView.ListSeparator" parent="Widget.TextView.ListSeparator">
    <item name="background">@drawable/list_section_divider_material</item>
    <item name="textAllCaps">true</item>

 - </style>

<style name="Widget.Material.Light.TextView.ListSeparator" parent="Widget.Material.TextView.ListSeparator"/>