Getting weird text back with EditText.toString() method in Android project. Why?

前端 未结 5 496
刺人心
刺人心 2020-12-11 13:08

I appear to have a fundamental gap in my understanding of an EditText object. I have an Activity+Layout with a single EditText object. After I type a few characters into t

5条回答
  •  庸人自扰
    2020-12-11 13:43

    Passing glance at the API suggests you should use the getText() method. toString() is a general method that applies to Object and all its subclasses (i.e., everything that isn't a primitive, to my knowledge). It's often overridden to supply more useful strings, but by default, it reports something just like what you posted - a sparse description and the object's hashcode. To be clear, the API defines toString() as:

    getClass().getName() + '@' + Integer.toHexString(hashCode())
    

提交回复
热议问题