OculusMalus OculusMalus - 1 month ago 7
Android Question

Button click adds text to EditText window

I'm building a text to speech app for android. I have a functioning EditText window. Whatever is typed into the window is spoken at the click of a button. What I want to do next is to build a sentence for output by adding text to the EditText window through button clicks.

This is my "speak" function. Can I manipulate and append to the editText.Text to accomplish my goal?

speak.Click += delegate
{
if (!string.IsNullOrEmpty(editText.Text))
textToSpeech.Speak(editText.Text, QueueMode.Flush, null);
};



<EditText
android:inputType="textMultiLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:text="What would you like to say?" />
<Button
android:text="Speak"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/speak" />

Answer

I may be misunderstanding the question but this may work for you:

String text = "whatever"; 
if (!TextUtils.isEmpty(text)) {
    editText.append(text);
}