How to read and display data in Android Studio?

-4

How to read data entered by the user in an EditText and display in a new activity in Android Studio? I've tried it in some ways, but displaying it in the other activity only displays "false".

    
asked by anonymous 28.05.2018 / 20:37

1 answer

0

Tip:

  

Learn Java or Kotlin before you begin, it will be very good for your   knowledge, because Android revolves around these languages   object-oriented programming.

How to:

private EditText mEditText;
mEditText = findViewById(R.id.NOME_DA_ID);

public void onClickButton(){
    Button mBtn= findViewById(R.id.NOME_DA_ID);
    mBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Bundle bundle = new Bundle();
            bundle.putString("TAG", mEditText.getText());
            Intent intent = new Intent(this, OutraActivity.class);
            intent.putExtras(bundle);
            startActivity(intent);
            finish();
        }
    });
}

Note:

EditText: Class that has all the context of where you are typing the value, create a private variable and create get and set of it to insert and pick values;

Bundle: Pass the information you want to another Activity, through a "TAG";

Intent: You will change Activity, along with the Bundle to pass the information to another Activity;

    
28.05.2018 / 21:03