Just like what paradox codee said, you need to do it programmatically. In your XML code, put a button that will let you get the value of your editText when clicked. Let's call it btn_concat.
<Button
android:id="@+id/btn_concat"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="20dp"/>
Now, if you're comfortable doing it on Java, here's how you can do it. On your MainActivity.java, put the following code. The comments // explain what each code does:
public class MainActivity extends AppCompatActivity {
// Put here the global objects
Button btn_concat;
EditText et_name;
TextView tvSentence;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Now, this is where you initialize your objects
// Find objects in layout by using their assigned IDs
btn_concat = findViewById(R.id.btn_concat);
tvSentence = findViewById(R.id.tvSentence);
et_name = findViewById(R.id.et_name);
// Set a click listener for the concat Button
btn_concat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// This is where we do what you're trying to do
// First, get the value of your EditText,
// and let's assign it to a String object called etValue
String etValue = et_name.getText.toString();
// Get the str_hello1 from resources
String hello = getResources().getString(R.string.str_hello1)
// Let's now update the TextView
String concatValue = hello + etValue;
tvSentence.setText(concatValue);
}
});
}
And that's it! Just enter anything on the editText, click the button, and you will see the concatenated text on the TextView. If you want, you can also do the concatenation as the user is typing. Just add a TextChangeListener to the EditText and put the code on onTextChanged interface.