Android学习|问题汇总(四)

问题预览

  • 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。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值