Converting TextView to String (kind of) Android

前端 未结 2 1083
后悔当初
后悔当初 2020-12-14 12:32

I have an object on my main.xml layout file called thefact that is TextView. I also have a string called sharefact. I want to save what text is in the TextView into the shar

2条回答
  •  独厮守ぢ
    2020-12-14 13:31

    Getting text from a TextView returns CharSequence. To convert CharSequence to String, toString() function is used.

    String sharedFact = theFact.getText().toString();
    

提交回复
热议问题