android studio android auto,如何在最新的android studio中自动导入缺失的类?(How to auto import missing class in the l...

如何在最新的android studio中自动导入缺失的类?(How to auto import missing class in the latest android studio?)

我正在关注Android Developer官方网站的基本教程。 还有一部分我无法工作。

该指令说如果要导入缺少的类,只需在类的顶部使用ALT + ENTER 。

当我这样做时,它不会导入丢失的类。 相反,它只是查看“ Create Test选项。

我是Android开发新手,希望你能帮助我。

I am following the basic tutorials in the Android Developer official site. And there's a part that I cant get to work.

The instruction said if you want to import the missing class just use ALT + ENTER on the top part of the class.

When I do that it wont import the missing classes. Instead its just viewing the Create Test option only.

I'm new in Android development I hope you can help me.

原文:https://stackoverflow.com/questions/35166679

更新时间:2020-03-15 21:03

最满意答案

仅当缺少的类有下划线时,自动导入才有效。 所以如果你看到一个红色的班级,点击靠近班级的某个地方的屏幕来调整光标位置,然后在班级名称加下划线时尝试ALT + ENTER 。

另一个选择是在输入类名时自动完成(可以通过ENTER或TAB完成,抱歉肌肉记忆使我忘记了哪些...)这将自动导入适当的类。

如果您正在使用第三方库并且这种库没有正确显示,请确保在您的gradle构建文件中为该库添加编译语句。

Auto import will only work if the missing class in question is underlined. So if you see a class in red, click on the screen somewhere close to the class to adjust the cursor position and then try ALT + ENTER once the class name is underlined.

Another option is to auto complete when typing the class name (which can be accomplished via ENTER or TAB, sorry muscle memory makes me forget which...) This will automatically import the appropriate class.

If you are using a third party library and this isn't appearing properly, make sure you add a compile statement for that library in your gradle build file.

2017-03-17

相关问答

我决定尝试使用Java To Kotlin转换。 所以我在Java中创建了一个新的Activity,并在java文档中写了上面的代码。 课程结束后,我在Android Studio中进行了Code -> Convert Java Class To Kotlin ,得到的Kotlin类有以下几行: val viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) 这完全编译。 我将不得不更多地了解哪一个是正确的,但是

...

看每一个工具都有自己不同的方式 为了导入,您可以使用 Alt + Enter 这里是Android工作室的快捷键 链接 为了便于您做到这一点,您可以在Androidstudio中使用Eclipse快捷方式 File -> Settings -> Keymap ->

Look everytool has its own different ways for import you can use Alt + Enter

...

转到文件 - >设置 - >编辑器 - >自动导入 - > Java,并做以下事情: 选择将导入的粘贴值添加到全部 在快速添加无误的进口选项上勾选标记,并“ 即时优化进口* Go to File -> Settings -> Editor -> Auto Import -> Java and make the below things: Select Insert imports on paste value to All Do tick mark on Add unambigious impor

...

对于Windows / Linux,您可以转到File - > Settings - > Editor - > General - > Auto Import - > Java并进行以下更改: 更改将Insert imports on paste值Insert imports on paste到All 标记Add unambigious imports on the fly选中时Add unambigious imports on the fly选项 在Mac上,在Android Studio -

...

您可以使用Intent将信息从一项活动转移到另一项活动。 您需要从edittext获取文本... String textFromEditText = editText.getText();

然后创建一个使用它的意图 Intent intent = new Intent(MainActivity.this, ActivityG.class);

intent.putExtra("message", textFromEditText);

startActivity(intent);

在你的Activ

...

如果你的意思是组织你的导入 ,那就是Android Studio(OS X)中的Ctrl+Alt+O 看看 OS X上的所有重要快捷方式.Android Studio基于IntelliJ Idea,因此它们都是有效的。 If you mean organizing your imports, that's Ctrl+Alt+O in Android Studio (OS X). Have a look here for all important shortcuts on OS X. Androi

...

您可以在Android Studio 1.2x From中设置Android Studio Auto导入 File->Setting->Editor->General->Auto Import 将Insert imports on paste上的Insert imports on paste更改为All , set动态Add unambiguous imports on the fly并optimize imports on the fly检查时动态optimize imports on the

...

对于Windows / Linux,您可以转至文件 - >设置 - >编辑 - >常规 - >自动导入 - > Java并进行以下更改: 更改在粘贴值上插入导入,使其不包含静态变量。 你可能不得不把它全部关闭。 For Windows/Linux, you can go to File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes: change Insert impor

...

Windows和osx的情况类似,因此不会有任何变化。 在android studio中去 file - > setting - > auto-import - >检查所有选项 喜欢 显示自动导入 优化导入选项 添加明确的导入选项 而已。 如上面评论中所述,检查链接在Android Studio中自动导入所有内容的快捷方式是什么? It is similar case for windows and osx so there will be no change. In android studio

...

仅当缺少的类有下划线时,自动导入才有效。 所以如果你看到一个红色的班级,点击靠近班级的某个地方的屏幕来调整光标位置,然后在班级名称加下划线时尝试ALT + ENTER 。 另一个选择是在输入类名时自动完成(可以通过ENTER或TAB完成,抱歉肌肉记忆使我忘记了哪些...)这将自动导入适当的类。 如果您正在使用第三方库并且这种库没有正确显示,请确保在您的gradle构建文件中为该库添加编译语句。 Auto import will only work if the missing class in q

...

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值