一、运行效果:
二、主函数MainActivity.java:
package com.example.a063_edittextapp; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity { private Button button; private EditText editText; private CharSequence string; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = findViewById(R.id.button); editText = findViewById(R.id.editTextTextPersonName); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { string = editText