gpt4 book ai didi

java - .length() 与 .getText().length() 与 .getText().toString().length()

转载 作者:IT老高 更新时间:2023-10-28 23:20:13 27 4
gpt4 key购买 nike

例如在下面的代码中abc是相等的。

EditText editText;
editText = (EditText) findViewById(R.id.edttxt);

editText.setText("1234");

int a, b, c;
a = editText.length();
b = editText.getText().length();
c = editText.getText().toString().length();

length()getText().length()getText().toString().length() 有什么区别>?

最佳答案

.length()getText().length()their current implementation 中是相同的.

.getText().toString().length() 会将 CharSequence 转换为纯 String,然后计算其长度。我希望在许多情况下返回与其他两个相同的值。但是,如果 CharSequence 类似于 SpannedString,我不能排除存在某种格式跨度的可能性(例如,ImageSpan ) 影响长度计算。

关于java - .length() 与 .getText().length() 与 .getText().toString().length(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36375402/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com