提前感谢您的帮助。我想将我的点文件扩展名从大写转换为小写。例如:ABCD.JPG >> ABCD.jpg , xyz.PNG >> xyz.png
if ( attachemtnDescription.toString().endsWith(".JPG") || attachemtnDescription.toString().endsWith(".jpg")) {
attachmentPreviewImg.setImageResource(R.drawable.ic_support_attachment_image);
因为我有很多附件类型要声明,所以要以大写和小写形式声明所有类型的附件很忙,所以我想减少我的代码。
我有一种方法可以从上/下转换进行转换,但是如何实现相同的方法 ...请提供相同的帮助。
EditText edit = (EditText)findViewById(R.id.email);
String input;
input = edit.getText().toString();
input = input.toLowerCase(); //converts the string to lowercase
or
input = input.toUpperCase();
最佳答案
我已经用过了,希望对大家也有帮助。
if (attachmentName.toString().toLowerCase().endsWith(".jpg") || attachmentName.toString().toLowerCase().endsWith(".jpeg")) {
attachmentPreviewImg.setImageResource(R.drawable.ic_support_attachment_image);
使用“.toLowerCase()”或“.toUpperCase()”。
关于Android:将 .extensions 转换为小写/大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44583275/