Converting TextView to String (kind of) Android

前端 未结 2 1078
后悔当初
后悔当初 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:15
    TextView theFact = (TextView) findViewById(R.id.theFact);
    String shareFact = theFact.getText().toString();
    
    0 讨论(0)
  • 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();
    
    0 讨论(0)
提交回复
热议问题