简体   繁体   English

android studio 找不到可绘制的图标

[英]android studio does not find drawable icon

I am trying to develop in android-studio on MAC and I am coming across a weird problem.我正在尝试在MAC上的android-studio 中进行开发,但遇到了一个奇怪的问题。 Within the activity code I can not refer to an image which lies in the mipmap folder.在活动代码中,我无法引用位于mipmap文件夹中的图像。 In particular I am have created a notification as:特别是我创建了一个通知:

...

Notification notify = new NotificationCompat.Builder(this)
    .setContentTitle(title)
    .setContentText(body)
    .setSmallIcon(R.drawable.ic_launcher)
    .setContentIntent(startPendingIntent)
    .build();

...

and I receive the error "cannot resolve symbol ic_launcher".我收到错误“无法解析符号 ic_launcher”。 Strange is also the problem, that I can not copy-paste the icons into the drawable folder which is empty.奇怪的是,我无法将图标复制粘贴到空的drawable文件夹中。 Where and how should I place the icons in order to visible within the code in android studio?我应该在哪里以及如何放置图标以便在android studio的代码中可见?

您需要使用R.mipmap.ic_launcher访问 drawable

Close Android Studio, then open up finder.关闭 Android Studio,然后打开 finder。 Go to the project directory.转到项目目录。 Go navigate to your project's mipmap folder.导航到项目的 mipmap 文件夹。 Copy the images, then go to the drawable folder and paste the images in their respective resolution folders.复制图像,然后转到 drawable 文件夹并将图像粘贴到各自的分辨率文件夹中。 Open up android studio again and they should be in the drawable folder.再次打开 android studio,它们应该在 drawable 文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM