MainActivity2.java In the example of multiple activities with contacts: Is there another way to go back to the previous Activity? If there is what would it be? bb.setOnClickListener(new View.OnClickListener() { public void onClick(View view) {finish(); } }); public class MainActivity2 extends AppCompatActivity { String[] phone = {"121121","131131","141141","151151"}; int[] image={R.drawable. img1,R.drawable. img2, R. drawable.img3, R. drawable.img4}; @Override protected void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.activity_main2); Intent intent2 = getIntent(); int i = intent2.getIntExtra ("index", 0); String name = intent2.getStringExtra ("name"); TextView tv1 = findViewById(R.id. text1); tv1.setText(name); ImageView iv = findViewById(R.id. cImage); iv.setImageResource(image[i]); TextView tv2 = findViewById(R.id. text2); tv2.setText(phone[i]); Button bb = findViewById(R.id.btn); bb.setOnClickListener(new View.OnClickListener() { public void onClick(View view) {finish(); } });}}
MainActivity2.java In the example of multiple activities with contacts: Is there another way to go back to the previous Activity? If there is what would it be? bb.setOnClickListener(new View.OnClickListener() { public void onClick(View view) {finish(); } }); public class MainActivity2 extends AppCompatActivity { String[] phone = {"121121","131131","141141","151151"}; int[] image={R.drawable. img1,R.drawable. img2, R. drawable.img3, R. drawable.img4}; @Override protected void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.activity_main2); Intent intent2 = getIntent(); int i = intent2.getIntExtra ("index", 0); String name = intent2.getStringExtra ("name"); TextView tv1 = findViewById(R.id. text1); tv1.setText(name); ImageView iv = findViewById(R.id. cImage); iv.setImageResource(image[i]); TextView tv2 = findViewById(R.id. text2); tv2.setText(phone[i]); Button bb = findViewById(R.id.btn); bb.setOnClickListener(new View.OnClickListener() { public void onClick(View view) {finish(); } });}}
Related questions
Question
![MainActivity2.java
In the example of multiple activities with contacts:
Is there another way to go back to the previous Activity? If there is what
would it be?
bb.setOnClickListener(new View.OnClickListener()
{ public void onClick(View view)
{finish(); } });
public class MainActivity2 extends AppCompatActivity {
String[] phone = {"121121","131131","141141","151151"};
int[]
image={R.drawable. img1,R.drawable. img2, R. drawable.img3, R. drawable.img4};
@Override
protected void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main2);
Intent intent2 = getIntent();
int i = intent2.getIntExtra ("index", 0);
String name = intent2.getStringExtra ("name");
TextView tv1 = findViewById(R.id. text1);
tv1.setText(name);
ImageView iv = findViewById(R.id. cImage);
iv.setImageResource(image[i]);
TextView tv2 = findViewById(R.id. text2);
tv2.setText(phone[i]);
Button bb = findViewById(R.id.btn);
bb.setOnClickListener (new View.OnClickListener()
{ public void onClick(View view)
{finish(); } });}}
1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1f4b5cd7-f3c9-4bf3-b5b4-fe47004d1590%2F07228d19-4357-49fb-8ab8-001dab2b39d7%2Fxz1ouel_processed.jpeg&w=3840&q=75)
Transcribed Image Text:MainActivity2.java
In the example of multiple activities with contacts:
Is there another way to go back to the previous Activity? If there is what
would it be?
bb.setOnClickListener(new View.OnClickListener()
{ public void onClick(View view)
{finish(); } });
public class MainActivity2 extends AppCompatActivity {
String[] phone = {"121121","131131","141141","151151"};
int[]
image={R.drawable. img1,R.drawable. img2, R. drawable.img3, R. drawable.img4};
@Override
protected void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main2);
Intent intent2 = getIntent();
int i = intent2.getIntExtra ("index", 0);
String name = intent2.getStringExtra ("name");
TextView tv1 = findViewById(R.id. text1);
tv1.setText(name);
ImageView iv = findViewById(R.id. cImage);
iv.setImageResource(image[i]);
TextView tv2 = findViewById(R.id. text2);
tv2.setText(phone[i]);
Button bb = findViewById(R.id.btn);
bb.setOnClickListener (new View.OnClickListener()
{ public void onClick(View view)
{finish(); } });}}
1
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images
