Main Activity - java
import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.EditText; import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; public class MainActivity extends AppCompatActivity { EditText et_playerName; String str_playerName; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EdgeToEdge.enable(this); setContentView(R.layout.activity_main); ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); return insets; }); et_playerName =(EditText) findViewById(R.id.et_playerName); } public void bt_start (View view) { str_playerName = et_playerName.getText().toString(); Intent i= new Intent(this, page1.class); i.putExtra("str_playerName", str_playerName); startActivity(i); } }
Leave a Comment