I'm new learner..
Write a complete code to show a Toast containing text from the EditText when the button is clicked. Assume in the xml file, EditText xml id=’MyEditText’ and button xml id=’MyButton’.
Button myButton = findViewById(R.id.MyButton); EditText editText = findViewById(R.id.MyEditText); myButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(this, editText.getText().toString(), Toast.LENGTH_SHORT).show(); } });
548k questions
547k answers
4 comments
86.3k users