0

Android Studio. Button for editing

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

12th Nov 2020, 5:18 PM
Victor Marquez
Victor Marquez - avatar
4 Answers
+ 5
You need two different activity with same XML layout, I explain you why. Through the intent you'd have to pass telephone, email and name. Intent intentpassvalue=new Intent(getApplicationContext(), SecondActivity.class); intentpassvalue.putExtra("name", names); intentpassvalue.putExtra("email", email); intentpassvalue.putExtra("number", number); In second activity you can show the information Text.setText(getIntent().getExtras().getString("names")); Text.setText(getIntent().getExtras().getString("email")); Text.setText(getIntent().getExtras().getString("number")); In the third you can reuse your layout, and pass intent to Second activity again Intent intentpassvalue=new Intent(getApplicationContext(), SecondActivity.class); intentpassvalue.putExtra(EditText.getText().toString(), names); intentpassvalue.putExtra(EditText2.getText().toString(), email); intentpassvalue.putExtra(EditText3.getText().toString(),number); I think in this way user can also, use EditText to edit information.
12th Nov 2020, 5:52 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 5
Victor Marquez in your second activity layout.
13th Nov 2020, 3:04 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
0
you can create a new activity for editing, by reusing the input layout. then use putExtra to send the required data to a new activity.
12th Nov 2020, 5:24 PM
Rei
Rei - avatar
0
And where do I add the Edit button? 0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
12th Nov 2020, 6:31 PM
Victor Marquez
Victor Marquez - avatar