发表于: 2018-10-11 23:23:26

0 703


一、今天完成的事情

    1.除了身份证验证,基本完成了任务三的其他要求,讲一下遇到的一些小问题吧。

    TextView调用setText()方法时,应该传入String类型的参数,如果传入其他类型比如int,编译器找不到正确的resource就会报错

    android.content.res.Resources$NotFoundException: String resource ID #0x1

     对于像我这样的新手来说,很容易想当然的传入一个int类型数据。

    2.然后我就调用toString()方法将int数据转为String,虽然可以通过编译,程序运行似乎也没什么问题,但是编译器的编辑界面会给出一个警告:

Number formatting does not take into account locale settings. Consider using String.format instead. less... (Ctrl+F1) 

When calling TextView#setText * Never call Number#toString() to format numbers; it will not handle fraction separators and locale-specific digits properly. Consider using String#format with proper format specifications (%d or %f) instead. * Do not pass a string literal (e.g. "Hello") to display text. Hardcoded text can not be properly translated to other languages. Consider using Android resource strings instead. * Do not build messages by concatenating text chunks. Such messages can not be properly translated.

    大概意思是toString()方法无法正确处理一些特殊的字符、符号,可能会导致转型错误,stackoverflow上推荐的方法是

     textView.setText(String.format(Locale.getDefault(), "%d", your_int));

     这样编译器的警告就消失了。


二、明天计划的事情

    实现身份证照片的真实性验证


三、遇到的问题

         

四、收获

    今天基本都是在做一些重复的事情。



返回列表 返回列表
评论

    分享到