防止导入android.R [英] Prevent import of android.R

查看:142
本文介绍了防止导入android.R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在IntelliJ Idea中防止android.R包中的autoimport?

How to prevent android.R package from autoimport in IntelliJ Idea?

当Idea导入android.R包时你真的很烦,你不能使用你的项目中的R类,除非你删除import android.R;你的代码中的一行。

It's really annoying when Idea import android.R package and you can't use R class from your project unless you delete "import android.R;" line in your code.

例如,我输入:

new ArrayAdapter<String>(getActivity(), android.R.layout.sim

然后按Ctrl +空格并选择完成中的第一项。我的代码现在看起来像这样:

then press Ctrl+Space and select first item in completion. My code now look like this:

new ArrayAdapter<String>(getActivity(), R.layout.simple_list_item_1

现在进口货物

import android.R;

当我继续打字,并达到那一刻:

When I continue typing, and reach that moment:

new ArrayAdapter<String>(getActivity(), R.layout.simple_list_item_1, 
                         getResources().getStringArray(R.array.

R.array 实际上是 android.R.array ,但这不是我所期望的。

R.array is actually android.R.array, but that's not what I expect.

推荐答案

您可以尝试以下选项:

禁用动态添加明确导入或添加 android.R 从导入和完成中排除

这篇关于防止导入android.R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆