0

Android Studio Edit Button

Hi, I'm creating a phone directory app that contains two Activities The first should allow the user to enter information for a contact with name, telephone number, address, email address (Everything is done and runs perfect). And the second Activity should show up displaying all the information about the contact(also too, everything is perfect). BUT On this second Activity, the user should be allowed to edit the contact information. Add a button for editing the information. Here is where I need help. Creating this button for editing. Idk how to do it. Thanks in advance PLSS help . Two people help me on one discuss. Thanks to those people ;). but I'm still don't get it Main Activity public class MainActivity extends AppCompatActivity { private Button addContactButton; private EditText etNameEditText; private EditText etPhoneEditText; private EditText etAddressEditText; private EditText etEmailEditText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); etNameEditText = (EditText) findViewById(R.id.etNameEditText); etPhoneEditText = (EditText) findViewById(R.id.etPhoneEditText); etAddressEditText = (EditText) findViewById(R.id.etAddressEditText); etEmailEditText = (EditText) findViewById(R.id.etEmailEditText); addContactButton = (Button) findViewById(R.id.addContactButton); addContactButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String name = etNameEditText.getText().toString(); int phone = Integer.parseInt(etPhoneEditText.getText().toString()); String address = etAddressEditText.getText().toString(); String email = etEmailEditText.getText().toString(); Intent intent = new Intent(MainActivity.this, ActivityList.class); int

12th Nov 2020, 7:50 PM
Victor Marquez
Victor Marquez - avatar
3 Answers
0
ActivityList public class ActivityList extends AppCompatActivity { private TextView resultTextView; private Button editTextButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); resultTextView = (TextView) findViewById(R.id.resultTextView); editTextButton = (Button) findViewById(R.id.editTextButton); Intent intent = getIntent(); String name = intent.getStringExtra("Name"); int phone = intent.getIntExtra("Phone", 0); String address = intent.getStringExtra("Address"); String email = intent.getStringExtra("Email"); resultTextView.setText( "\n\nName: " + name + "\n\nPhone: " + phone + "\n\nAddress: " + address + "\n\nEmail: " + email); } }
12th Nov 2020, 7:51 PM
Victor Marquez
Victor Marquez - avatar
0
EditTextActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); resultTextView = (TextView) findViewById(R.id.resultTextView); etNameEditText = (EditText) findViewById(R.id.etNameEditText); etPhoneEditText = (EditText) findViewById(R.id.etPhoneEditText); etAddressEditText = (EditText) findViewById(R.id.etAddressEditText); etEmailEditText = (EditText) findViewById(R.id.etEmailEditText); addContactButton = (Button) findViewById(R.id.editTextButton); Intent intent = getIntent(); Intent intentpassvalue=new Intent(getApplicationContext(), ActivityList.class); intentpassvalue.putExtra(etNameEditText.getText().toString(), "name"); intentpassvalue.putExtra(etEmailEditText.getText().toString(), "email"); intentpassvalue.putExtra(etPhoneEditText.getText().toString(), "phone"); intentpassvalue.putExtra(etAddressEditText.getText().toString(),"address"); } }
12th Nov 2020, 7:52 PM
Victor Marquez
Victor Marquez - avatar
0
Main activity { String name = etNameEditText.getText().toString(); int phone = Integer.parseInt(etPhoneEditText.getText().toString()); String address = etAddressEditText.getText().toString(); String email = etEmailEditText.getText().toString(); Intent intent = new Intent(MainActivity.this, ActivityList.class); intent.putExtra("Name", name); intent.putExtra("Phone", phone); intent.putExtra("Address", address); intent.putExtra("Email", email); startActivity(intent); }
12th Nov 2020, 7:52 PM
Victor Marquez
Victor Marquez - avatar