结果图: public class Task1Activity extends AppCompatActivity { private EditText etName; private ImageButton btnClick; /** * ATTENTION: This was auto-generated to implement the App Indexing API. * See https://g.co/AppIndexing/AndroidStudio for more information. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_task1); final EditText etName = (EditText) findViewById(R.id.etName); btnClick = (ImageButton) findViewById(R.id.btnClick); btnClick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(Task1Activity.this, "hello" +etName.getText().toString(), Toast.LENGTH_LONG).show(); } }); } }