问题预览
- 1)怎么判断EditText是否为空?
- 2)创建java类中类出现is not an enclosing class
- 3)关于String.replace
- 4)Error type 3 Error: Activity class {} does not exist
- 5)Failed to open zip file. Gradle’s dependency cache may be corrupt
(this sometimes occurs after a network connection timeout.)
1.怎么判断EditText是否为空?
- 用
TextUtils.isEmpty(XX.getText())
来判断
TextUtils.isEmpty()在字符串为null或者"“的情况下,都是可以用TextUtils.isEmpty()来进行判断的,因为当”"情况下,str.length()==0,所以同样也会返回true。
2.创建java类中类出现is not an enclosing class
public class A {
public class B {
}
};
需要实例B类时,使用A.B ab = new A.B();
会出现一个错误 “is not an enclosing class”
解决办法:
A a = new A();
A.B ab = a.new B();
没有静态(static)的类中类不能使用外部类进行.操作,必须用实例来进行实例化类中类。
3.关于String.replace
String对象是不可变的。
public String replace(char oldChar,char newChar)
返回使用newChar替换此字符串中所有出现的oldChar而产生的字符串,需要一个返回值。
4.Error type 3 Error: Activity class {} does not exist
- 部分手机在点击应用卸载以后,再用AndroidStudio往手机上run程序一直报错,Activity class {} does not exist,解决办法:
adb uninstall {com.xxx.xxx(包名)}
,卸载apk包。
5.Failed to open zip file. Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
- 解决方法:在gradle链接中:https://services.gradle.org/distributions/
找到你需要的版本号。下载并解压到此目录中:C:\Users\Administrator.gradle\wrapper\dists。
之后在AS中打开设置:File->settings。