CRTC Electronics

Click here to edit subtitle

Reading and Writeing to a Text Box

Veriables

In main.xml add two text boxes, 

  • one for a message
  • one for a phone number label each

In onCreate() make to variables, 

  • one for the message text box
  • one for a phone number text box




private TextView phoneNumber;

private TextView textMessage;

Link

link the variable to the text boxes

phoneNumber_ = (TextView) findViewById(R.id.editTextPhoneNumber);

textMessage_ = (TextView) findViewById(R.id.editTextMessage);

Sending the Text

When ready to send text call:

sm.sendTextMessage


Get the text from phoneNumber_ then convert it to a string.



Get the text from textMessage_ then convert it to a string.


sm.sendTextMessage(



phoneNumber_.getText().toString(),


null,


textMessage_.getText().toString(),


null,


null);

Writing to a text box

Put text into a text box

textMessage_.setText("defalt text here");