Android 编程如何将小部件转换或转换为 java 字符串

Android Programming how can i convert or cast widget to java string

我基本上是在 Android 中获取 Textview 的值,然后对该文本进行哈希处理,但我遇到异常 String cannot be converted into Android.Widget.TextView 这是我的简单代码

TextView mypassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.registration);
    mypassword= (TextView)findViewById(R.id.password);
    mypassword= BCrypt.hashpw(mypassword,BCrypt.gensalt(12));
}

hashpw接受以下参数 hashpw(Java.lang.String, String) 我一直在尝试投射这个但没有任何建议?

您可以通过在 TextView 上调用 getText().toString() 来获得 TextView 中文本的 String 值。