为什么Android Studio会为某些类输入完整路径? [英] Why does Android Studio enter the full path for some classes?

查看:174
本文介绍了为什么Android Studio会为某些类输入完整路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下用于创建自定义适配器的代码,并且android studio默认为程序包的完整路径.这并不总是这样.我想知道发生了什么变化.即使在类的顶部声明了 localNetView ,它也不知道是什么.为什么Android Studio会这样做?不做任何更改就找不到类.

I have the following code for creating a custom adapter and android studio is defaulting to the full path of my package. This was not always like this. I wonder what has changed. And it doesn't know what localNetView is even though is declare at the top of my class. Why does Android Studio do it like this? Without making any changes can't find the classes.

private ListView localNetListView;
private Adapter localNetAdapter;

localNetListView  = (ListView) findViewById(R.id.local_network);
localNetAdapter = new org.pctechtips.netdroid.HostAdapter(this, R.layout.list_main, localIfaceInfo);
localNetListView.setAdapter(localNetAdapter);

推荐答案

确保未选中文件">设置">编辑器">代码样式">"Java">导入"选项卡下的使用完全限定的类名"选项.

Make sure the "Use fully qualified class names" option under File > Settings > Editor > Code Style > Java > Imports tab is unchecked.

如果仅在文件中发生这种情况,请手动检查导入,并查看是否导入了另一个具有相同名称(和不同包)的类,然后删除其导入行.

If this is only happening to a file, check the imports manually and see if another class with the same name (and different package) is imported, and remove its import line.

这篇关于为什么Android Studio会为某些类输入完整路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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